File: DenseGenMatProd.cpp

package info (click to toggle)
spectra 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,788 kB
  • sloc: cpp: 23,044; ansic: 175; fortran: 131; makefile: 90
file content (28 lines) | stat: -rw-r--r-- 801 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

#include <Spectra/MatOp/DenseGenMatProd.h>
#include <Eigen/Dense>

#include "catch.hpp"

using namespace Spectra;

using Eigen::Matrix;
using Eigen::Index;

TEMPLATE_TEST_CASE("matrix operations", "[DenseGenMatProd]", float, double)
{
    std::srand(123);
    constexpr Index n = 100;

    Matrix<TestType, -1, -1> mat1 = Matrix<TestType, -1, -1>::Random(n, n);
    Matrix<TestType, -1, -1> mat2 = Matrix<TestType, -1, -1>::Random(n, n);

    DenseGenMatProd<TestType> dense1(mat1);
    Matrix<TestType, -1, -1> xs = dense1 * mat2;
    Matrix<TestType, -1, -1> ys = mat1 * mat2;

    INFO("The matrix-matrix product must be the same as in eigen.")
    REQUIRE(xs.isApprox(ys));
    INFO("The accesor operator must produce the same element as in eigen")
    REQUIRE(mat1(23, 87) == dense1(23, 87));
}