11 const size_t ntests = 100;
15 for (
size_t i = 0; i < ntests; i++) {
26 TCudaMatrix ACuda(
A), ATCuda(AT), BCuda(
B), BTCuda(BT), CCuda(C);
32 maximumError = std::max(error, maximumError);
38 maximumError = std::max(error, maximumError);
44 maximumError = std::max(error, maximumError);
52 const size_t ntests = 10;
56 for (
size_t i = 0; i < ntests; i++) {
71 maximumError = std::max(error, maximumError);
79 const size_t ntests = 10;
82 for (
size_t i = 0; i < ntests; i++) {
92 for (
size_t j = 0; j < (size_t)
A.GetNrows(); j++) {
93 for (
size_t k = 0; k < (size_t)
A.GetNcols(); k++) {
101 maximumError = std::max(error, maximumError);
109 const size_t ntests = 10;
112 for (
size_t i = 0; i < ntests; i++) {
114 m = rand() % 1000 + 1;
115 n = rand() % 1000 + 1;
119 for (
size_t j = 0; j <
m; j++) {
120 for (
size_t k = 0; k <
n; k++) {
133 maximumError = std::max(error, maximumError);
135 for (
size_t j = 0; j <
n; j++) {
137 error = std::abs(
B(0,j) - m);
138 maximumError = std::max(error, maximumError);
147 const size_t ntests = 10;
150 for (
size_t i = 0; i < ntests; i++) {
152 m = rand() % 1000 + 1;
153 n = rand() % 1000 + 1;
168 maximumError = std::max(error, maximumError);
178 std::cout <<
"Testing reduction: max. rel. error = ";
179 std::cout << error << std::endl;
182 std::cout <<
"Testing scale_add: max. rel. error = ";
183 std::cout << error << std::endl;
186 std::cout <<
"Testing hadamard: max. rel. error = ";
187 std::cout << error << std::endl;
190 std::cout <<
"Testing multiplication: max. rel. error = ";
191 std::cout << error << std::endl;
194 std::cout <<
"Testing add_row_wise: max. rel. error = ";
195 std::cout << error << std::endl;
auto maximumRelativeError(const Matrix1 &X, const Matrix2 &Y) -> decltype(X(0, 0))
Compute the maximum, element-wise relative error of the matrices X and Y normalized by the element of...
void randomMatrix(AMatrix &X)
Fill matrix with random, Gaussian-distributed values.
static void MultiplyTranspose(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &input, const TMatrixT< Scalar_t > &weights)
Matrix-multiply input with the transpose of and write the results into output.
static void MultiplyTranspose(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &input, const TCudaMatrix< AFloat > &weights)
Matrix-multiply input with the transpose of and write the results into output.
static void ScaleAdd(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B, Scalar_t beta=1.0)
Adds a the elements in matrix B scaled by c to the elements in the matrix A.
static void AddRowWise(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &biases)
Add the vectors biases row-wise to the matrix output.
static void Hadamard(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B)
In-place Hadamard (element-wise) product of matrices A and B with the result being written into A...
double beta(double x, double y)
Calculates the beta function.
static void AddRowWise(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &biases)
Add the vectors biases row-wise to the matrix output.
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Create a matrix C such that C = A' * B.
Double_t testAddRowWise()
static void Multiply(TCudaMatrix< AFloat > &C, const TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B)
Standard multiplication of two matrices A and B with the result being written into C...
static void ScaleAdd(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B, Scalar_t beta=1.0)
Adds a the elements in matrix B scaled by c to the elements in the matrix A.
static AFloat Sum(const TCudaMatrix< AFloat > &A)
Compute the sum of all elements in A.
static void InitializeZero(TCudaMatrix< AFloat > &A)
static void TransposeMultiply(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &input, const TCudaMatrix< AFloat > &Weights)
Matrix multiplication of two matrices A and B^T (transposed) with the result being written into C...
static void SumColumns(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
Sum columns of (m x n) matrixx A and write the results into the first m elements in A...
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B.