/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * PANIC * Portable Algorithms and Numerics In C++ * * Scientific computing from scratch, with feeling. * * Copyright (c) 2026 Michelle Bausager * * This file is part of PANIC. * * PANIC is free software licensed under the GNU General Public License v3.0 or later. * You may redistribute and/or modify it under the terms of the GPL. * * PANIC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the LICENSE file for the full license text. * * SPDX-License-Identifier: GPL-3.0-or-later * *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * Project Name: PANIC * Module Name: math * File Name: matmul.hpp * Revision: 0.1.0 * Date: 24-06-2026 * Author: Michelle Bausager * * Description: * Functions to print out tensors with std::cout << x std::endl; * *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #pragma one //--------------------------------------------------------------------------------------------------------------------------- // INCLUDE DESCRIPTION //----------------------------------------------------------------------------------------------------- #include // for panic::real_matrix //--------------------------------------------------------------------------------------------------------------------------- // DEFINE DESCRIPTION //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- // VARIABLE DESCRIPTION //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- // FUNCTION PROTOTYPE //--------------------------------------------------------------------------------------------------------------------------- namespace panic{ namespace math{ //-------------------------------------------------------------------------------------------------------------------------- // Function Name : panic::math::matmul // // Description: // Multiplies to panic::tensor::real_matrix // C(2,4) = A(2,3) * B(3,4) // // Inputs: // // A const panic::tensor::real_matrix& // // B const panic::tensor::real_matrix& // // Outputs: // C panic::tensor::real_matrix& // // Returns: // bool // // Notes: // If input matrix dimentions are not correct, output is a empty matrix and returns false. // The C matrix is resized if nessessary. //-------------------------------------------------------------------------------------------------------------------------- template bool matmul(const panic::tensor::matrix& A, const panic::tensor::matrix& B, panic::tensor::matrix& C); //-------------------------------------------------------------------------------------------------------------------------- // Function Name : panic::math::matmul // // Description: // Multiplies to panic::tensor::real_matrix // C(2,4) = A(2,3) * B(3,4) // // Inputs: // // A const panic::tensor::real_matrix& // // B const panic::tensor::real_matrix& // // Outputs: // None. // // Returns: // C panic::tensor::real_matrix& // // Notes: // If input matrix dimentions are not correct, returns an a empty matrix. // Creates new matrix, C, for the result. //-------------------------------------------------------------------------------------------------------------------------- template panic::tensor::matrix matmul(const panic::tensor::matrix& A, const panic::tensor::matrix& B); } // namespace math } // namespace panic