25 template<
typename Architecture_t>
27 ->
typename Architecture_t::Scalar_t
30 using Scalar_t =
typename Architecture_t::Scalar_t;
31 using Matrix_t =
typename Architecture_t::Matrix_t;
33 Scalar_t maximumError = 0.0;
35 for (
size_t t = 0; t < ntests; t++) {
42 BTRef(n,k), CRef(m,n);
48 Matrix_t
A(ARef), A2(A2Ref), AT(ATRef),
B(BRef), BT(BTRef),
C(CRef);
52 Architecture_t::Multiply(C,
A,
B);
54 maximumError = std::max(error, maximumError);
57 CRef.
TMult(ATRef,BRef);
58 Architecture_t::TransposeMultiply(C, AT,
B);
60 maximumError = std::max(error, maximumError);
63 CRef.
MultT(ARef,BTRef);
64 Architecture_t::MultiplyTranspose(C,
A, BT);
66 maximumError = std::max(error, maximumError);
69 for (
size_t i = 0; i < (size_t) ARef.GetNrows(); i++) {
70 for (
size_t j = 0; j < (size_t) ARef.GetNcols(); j++) {
71 ARef(i,j) *= A2Ref(i,j);
74 Architecture_t::Hadamard(
A, A2);
76 maximumError = std::max(error, maximumError);
86 template<
typename Architecture_t>
88 ->
typename Architecture_t::Scalar_t
91 using Scalar_t =
typename Architecture_t::Scalar_t;
92 using Matrix_t =
typename Architecture_t::Matrix_t;
94 Scalar_t maximumError = 0.0;
95 for (
size_t t = 0; t < ntests; t++) {
100 m = rand() % 100 + 1;
101 n = rand() % 100 + 1;
105 for (
size_t i = 0; i < (size_t) ARef.GetNrows(); i++) {
106 for (
size_t j = 0; j < (size_t) ARef.GetNcols(); j++) {
108 if (i == 0) BRef(j, 0) = m * j;
112 Matrix_t
A(ARef),
B(n, 1);
113 Architecture_t::SumColumns(B,
A);
116 maximumError = std::max(error, maximumError);
void randomMatrix(AMatrix &X)
Fill matrix with random, Gaussian-distributed values.
auto maximumRelativeError(const AMatrix &X, const AMatrix &Y) -> decltype(X(0, 0))
Compute the maximum, element-wise relative error of the matrices X and Y normalized by the element of...
auto testSumColumns(size_t ntests) -> typename Architecture_t::Scalar_t
Test the summing over columns by summing by the sums obtained from a matrix filled with column indice...
auto testMultiplication(size_t ntests) -> typename Architecture_t::Scalar_t
Test multiplication (standard, transposed, hadamard) operation on architecture specific matrix types ...
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B^T.
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Create a matrix C such that C = A' * B.
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B.