Comment rewrite
This commit is contained in:
+223
-289
@@ -1,4 +1,5 @@
|
||||
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
*
|
||||
* PANIC
|
||||
* Portable Algorithms and Numerics In C++
|
||||
@@ -30,333 +31,266 @@
|
||||
* Description:
|
||||
* Functions to add panic::tensor togther;
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma one
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// INCLUDE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
#include <tensor/vector.hpp> // for panic::real_vector (uint_vector, int_vector)
|
||||
#include <tensor/matrix.hpp> // for panic::real_matrix (uint_matrix, int_matrix)
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// DEFINE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
* @file add.hpp
|
||||
* @brief Public API for element-wise addition operations on PANIC vectors and matrices.
|
||||
*
|
||||
* This header contains the declarations that users of the math module should call.
|
||||
* The comments here describe how each function is used, what dimensions are required,
|
||||
* and what is returned on failure.
|
||||
*
|
||||
* Implementation details, OpenMP thresholds, and explicit template instantiations are
|
||||
* kept in add.cpp.
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// VARIABLE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
#include <tensor/vector.hpp> // for panic::vector
|
||||
#include <tensor/matrix.hpp> // for panic::matrix
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// FUNCTION PROTOTYPE
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
namespace panic{
|
||||
namespace math{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds a scaler to a panic::tensor::vector
|
||||
// c(2) = a(2) + k
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// a const panic::tensor::vector<T>&
|
||||
//
|
||||
// k const <T>
|
||||
//
|
||||
// Outputs:
|
||||
// c panic::tensor::vector<T>&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// The c vector is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Adds a scalar to every element of a vector.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* c[i] = a[i] + k
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param a Input vector.
|
||||
* @param k Scalar value added to each element of @p a.
|
||||
* @param c Output vector. Resized to match @p a.
|
||||
*
|
||||
* @return true if @p c was resized and filled successfully.
|
||||
* @return false if resizing @p c failed.
|
||||
*
|
||||
* @note This overload writes the result into an existing vector to avoid
|
||||
* unnecessary temporary allocations.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add(const panic::tensor::vector<T>& a, const T k, panic::tensor::vector<T>& c);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds a scaler to a panic::tensor::vector
|
||||
// c(2) = a(2) + k
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// a const panic::tensor::vector<T>&
|
||||
//
|
||||
// k const <T>
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// c panic::tensor::vector<T>
|
||||
//
|
||||
// Notes:
|
||||
// Makes new vector and returns the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns a new vector containing a scalar added to every element.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result[i] = a[i] + k
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param a Input vector.
|
||||
* @param k Scalar value added to each element of @p a.
|
||||
*
|
||||
* @return A new vector containing the result.
|
||||
* @return An empty vector if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::vector<T> add(const panic::tensor::vector<T>& a, const T k);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::vector
|
||||
// c(2) = a(2) + b(2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// a const panic::tensor::vector<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// c panic::tensor::vector<T>&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, output is a empty vector and returns false.
|
||||
// The c vector is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a vector elementwise too a vector.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* c[i] = a[i] + b[i]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param a First vector.
|
||||
* @param b Second vector. Must have size of @p a
|
||||
* @param c Output vector. Resized to match @p a.
|
||||
*
|
||||
* @return true if @p c was resized and filled successfully.
|
||||
* @return false if vector sizes do not match or resizing @p c failed.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add(const panic::tensor::vector<T>& a, const panic::tensor::vector<T>& b, panic::tensor::vector<T>& c);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::vector
|
||||
// c(2) = a(2) + b(2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// a const panic::tensor::vector<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// c panic::tensor::vector<T>
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, return is an empty vector.
|
||||
// Makes new vector and returns the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns a new vector containing a vector added elementwise.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result[i] = a[i] + b[i]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param a First vector.
|
||||
* @param b Second vector. Must have size of @p a
|
||||
* @param k Scalar value added to each element of @p a.
|
||||
*
|
||||
* @return A new vector containing the result.
|
||||
* @return An empty vector if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::vector<T> add(const panic::tensor::vector<T>& a, const panic::tensor::vector<T>& b);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds a scaler to a panic::tensor::matrix
|
||||
// C(2,2) = A(2,2) + k
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// k const T
|
||||
//
|
||||
// Outputs:
|
||||
// C panic::tensor::matrix<T>&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// The C matrix is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a scalar to every element of a matix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* C(i,j) = A(i,j) + k
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Input matrix.
|
||||
* @param k Scalar value added to each element of @p A.
|
||||
* @param C Output Matrix. Resized to match @p A.
|
||||
*
|
||||
* @return true if @p C was resized and filled successfully.
|
||||
* @return false if resizing @p C failed.
|
||||
*
|
||||
* @note This overload writes the result into an existing vector to avoid
|
||||
* unnecessary temporary allocations.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add(const panic::tensor::matrix<T>& A, const T k, panic::tensor::matrix<T>& C);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds a scaler to a panic::tensor::matrix
|
||||
// C(2,2) = A(2,2) + k
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// k const T
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// C panic::tensor::matrix<T>
|
||||
//
|
||||
// Notes:
|
||||
// Creates new matrix, C, for the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns a new matrix containing a scalar added to every element.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result(i,j) = A(i,j) + k
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Input matrix.
|
||||
* @param k Scalar value added to each element of @p A.
|
||||
*
|
||||
* @return A new matrix containing the result.
|
||||
* @return An empty matrix if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::matrix<T> add(const panic::tensor::matrix<T>& A, const T k);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,2) = A(2,2) + B(2,2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// B const panic::tensor::matrix<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// C panic::tensor::matrix<T>&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// If input matrix dimentions are not correct, outputs an a empty matrix and returns false.
|
||||
// The C matrix is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a matrix elementwise too a matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* C(i,j) = A(i,j) + B(i,j)
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A First matrix.
|
||||
* @param B Second matrix. Must have size of @p A.
|
||||
* @param C Output matrix. Resized to match @p A.
|
||||
*
|
||||
* @return true if @p C was resized and filled successfully.
|
||||
* @return false if vector sizes do not match or resizing @p c failed.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add(const panic::tensor::matrix<T>& A, const panic::tensor::matrix<T>& B, panic::tensor::matrix<T>& C);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,2) = A(2,2) + B(2,2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// B const panic::tensor::matrix<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// C panic::tensor::matrix<T>
|
||||
//
|
||||
// Notes:
|
||||
// If input matrix dimentions are not correct, returns an a empty matrix.
|
||||
// Creates new matrix, C, for the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns a new matrix containing a matrix added elementwise.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result(i,j) = A(i,j) + B(i,j)
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Input matrix.
|
||||
* @param B Second matrix. Must have size of @p A.
|
||||
*
|
||||
* @return A new matrix containing the result.
|
||||
* @return An empty matrix if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::matrix<T> add(const panic::tensor::matrix<T>& A, const panic::tensor::matrix<T>& B);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add_rowwise
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,3) = A(2,3) + b(2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// C panic::tensor::matrix&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, outputs an a empty matrix and returns false.
|
||||
// The C matrix is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a vector rowwise too a matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* C(i,j) = A(i,j) + b[i]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Matrix.
|
||||
* @param b Vector. Must have size of @p A.cols().
|
||||
* @param C Output matrix. Resized to match @p A.
|
||||
*
|
||||
* @return true if @p C was resized and filled successfully.
|
||||
* @return false if vector sizes do not match or resizing @p c failed.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add_rowwise(const panic::tensor::matrix<T>& A, const panic::tensor::vector<T>& b, panic::tensor::matrix<T>& C);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add_rowwise
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,3) = A(2,3) + b(2)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// C panic::tensor::matrix<T>&
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, returns an a empty matrix.
|
||||
// Creates new matrix, C, for the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a vector rowwise too a matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result(i,j) = A(i,j) + b[i]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Matrix.
|
||||
* @param b Vector. Must have size of @p A.cols().
|
||||
*
|
||||
* @return A new matrix containing the result.
|
||||
* @return An empty matrix if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::matrix<T> add_rowwise(const panic::tensor::matrix<T>& A, const panic::tensor::vector<T>& b);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add_colwise
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,3) = A(2,3) + b(3)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// C panic::tensor::matrix&
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, outputs an a empty matrix and returns false.
|
||||
// The C matrix is resized if nessessary.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a vector colwise too a matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* C(i,j) = A(i,j) + b[j]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Matrix.
|
||||
* @param b Vector. Must have size of @p A.rows().
|
||||
* @param C Output matrix. Resized to match @p A.
|
||||
*
|
||||
* @return true if @p C was resized and filled successfully.
|
||||
* @return false if vector sizes do not match or resizing @p c failed.
|
||||
*/
|
||||
template <typename T>
|
||||
bool add_colwise(const panic::tensor::matrix<T>& A, const panic::tensor::vector<T>& b, panic::tensor::matrix<T>& C);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::math::add_colwise
|
||||
//
|
||||
// Description:
|
||||
// Adds two panic::tensor::matrix
|
||||
// C(2,3) = A(2,3) + b(3)
|
||||
//
|
||||
// Inputs:
|
||||
//
|
||||
// A const panic::tensor::matrix<T>&
|
||||
//
|
||||
// b const panic::tensor::vector<T>&
|
||||
//
|
||||
// Outputs:
|
||||
// None.
|
||||
//
|
||||
// Returns:
|
||||
// C panic::tensor::matrix<T>&
|
||||
//
|
||||
// Notes:
|
||||
// If input vector dimentions are not correct, returns an a empty matrix.
|
||||
// Creates new matrix, C, for the result.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Adds a vector colwise too a matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result(i,j) = A(i,j) + b[j]
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A Matrix.
|
||||
* @param b Vector. Must have size of @p A.rows().
|
||||
*
|
||||
* @return A new matrix containing the result.
|
||||
* @return An empty matrix if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::matrix<T> add_colwise(const panic::tensor::matrix<T>& A, const panic::tensor::vector<T>& b);
|
||||
|
||||
|
||||
+37
-47
@@ -31,7 +31,7 @@
|
||||
* Functions to print out tensors with std::cout << x std::endl;
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma one
|
||||
#pragma once
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// INCLUDE DESCRIPTION
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
@@ -50,55 +50,45 @@
|
||||
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.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Calculates matrix multiplication of two matrices.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* C(n, p) = A(n,m) + B(m,p)
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A First matrix.
|
||||
* @param B Second matrix. @ p B.rows needs to be the size of @p A.cols.
|
||||
* @param C Output matrix. Resized to C(A.rows, B.cols).
|
||||
*
|
||||
* @return true if @p C was resized and filled successfully.
|
||||
* @return false if resizing @p C failed or A==B.
|
||||
*
|
||||
* @note This overload writes the result into an existing matrix to avoid
|
||||
* unnecessary temporary allocations.
|
||||
*/
|
||||
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.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns a new matrix of multiplication of two matrices.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* result(n, p) = A(n,m) + B(m,p)
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param A First matrix.
|
||||
* @param B Second matrix. @ p B.rows needs to be the size of @p A.cols.
|
||||
*
|
||||
* @return A new matrix containing the result.
|
||||
* @return An empty vector if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new matrix.
|
||||
*/
|
||||
template <typename T>
|
||||
panic::tensor::matrix<T> matmul(const panic::tensor::matrix<T>& A, const panic::tensor::matrix<T>& B);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user