MyraMath
sparse_expression


Source: tests/sparse/expression.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
14 
15 // Algorithms.
16 #include <myramath/sparse/expr.h>
18 
19 // Reporting.
21 #include <tests/myratest.h>
22 
23 using namespace myra;
24 
25 ADD_TEST("sparse_expression","[sparse]")
26  {
27  typedef std::complex<double> Z;
28  auto A = SparseMatrix<Z>::random(5,5,10);
29  myra::out() << A << std::endl;
30  myra::out() << expr(A) << std::endl;
31  conjugate_inplace(A);
32  myra::out() << expr(A) << std::endl;
33  myra::out() << conjugate(A) << std::endl;
34  }
static SparseMatrix< Number > random(int I, int J, int N)
Generates a random SparseMatrix with size IxJ and (approximately) N nonzeros.
Definition: SparseMatrix.cpp:493
General purpose compressed-sparse-column (CSC) container.
Definition: syntax.dox:1
Returns a conjugated copy of a SparseMatrix.
Overloads expr() for SparseMatrix<Number> and Pattern.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]

size 5 by 5 SparseMatrix of std::complex<double> (8 nz):
A(:,j0) = 2 nz [ i0,(-0.267375,-0.48846) i3,(-0.46022,0.368489) ]
A(:,j1) = 1 nz [ i1,(-0.699007,-0.012265) ]
A(:,j2) = 2 nz [ i1,(-0.877514,0.697058) i3,(-0.589138,0.668904) ]
A(:,j3) = 2 nz [ i3,(0.655384,-0.0490884) i4,(-0.577969,-0.688802) ]
A(:,j4) = 1 nz [ i1,(-0.862937,-0.0285375) ]
size 5 by 5 arity-2 Expression of std::complex<double>:
[ (-0.267375,-0.48846) (0,0) (0,0) (0,0) (0,0) ]
[ (0,0) (-0.699007,-0.012265) (-0.877514,0.697058) (0,0) (-0.862937,-0.0285375) ]
[ (0,0) (0,0) (0,0) (0,0) (0,0) ]
[ (-0.46022,0.368489) (0,0) (-0.589138,0.668904) (0.655384,-0.0490884) (0,0) ]
[ (0,0) (0,0) (0,0) (-0.577969,-0.688802) (0,0) ]
size 5 by 5 arity-2 Expression of std::complex<double>:
[ (-0.267375,0.48846) (0,0) (0,0) (0,0) (0,0) ]
[ (0,0) (-0.699007,0.012265) (-0.877514,-0.697058) (0,0) (-0.862937,0.0285375) ]
[ (0,0) (0,0) (0,0) (0,0) (0,0) ]
[ (-0.46022,-0.368489) (0,0) (-0.589138,-0.668904) (0.655384,0.0490884) (0,0) ]
[ (0,0) (0,0) (0,0) (-0.577969,0.688802) (0,0) ]
size 5 by 5 SparseMatrix of std::complex<double> (8 nz):
A(:,j0) = 2 nz [ i0,(-0.267375,-0.48846) i3,(-0.46022,0.368489) ]
A(:,j1) = 1 nz [ i1,(-0.699007,-0.012265) ]
A(:,j2) = 2 nz [ i1,(-0.877514,0.697058) i3,(-0.589138,0.668904) ]
A(:,j3) = 2 nz [ i3,(0.655384,-0.0490884) i4,(-0.577969,-0.688802) ]
A(:,j4) = 1 nz [ i1,(-0.862937,-0.0285375) ]


Go back to Summary of /test programs.