Files
panic/include/math/matmul.hpp
T
Bausager 189d605bfa Dense Layer, Add
added the dense layer with a forward functions. I also made the add functions for most cases.
2026-06-25 19:43:07 +02:00

107 lines
4.1 KiB
C++

/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 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 <tensor/matrix.hpp> // 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 <typename T>
bool matmul(const panic::tensor::matrix<T>& A, const panic::tensor::matrix<T>& B, panic::tensor::matrix<T>& 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 <typename T>
panic::tensor::matrix<T> matmul(const panic::tensor::matrix<T>& A, const panic::tensor::matrix<T>& B);
} // namespace math
} // namespace panic