ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
testMatrixOfElements.cc
Go to the documentation of this file.
1/*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
28#include "acl/acl.h"
29#include "acl/aclGenerators.h"
33#include "math/aslMatrices.h"
36
37using namespace asl;
38using namespace acl;
39using namespace std;
40
42{
43 cout << "Test of \"Matrix Operations\" function..." << flush;
44
49
50 Kernel k;
51 {
52 using namespace elementOperators;
53 k << (vec0=generateVEConstant(0.1f,1.f,2.f));
54 k << (vec1=(elementProduct(generateVEConstant(0.f,1.f,2.f),vec0)*generateVEConstant(1.f,0.f,2.f))*vec0);
55 }
56 k.setup();
57 k.compute();
58
60 copy(vec1[0], output);
61
62 bool status(output[1] == 20.5);
64
65 return status;
66}
67
68
70{
71 cout << "Test of \"System Solve Cramer's rule\" function..." << flush;
72
77
78 auto matA(generateMEConstant(makeAMatr(makeAVec(4.,1.),makeAVec(1.,3.))));
79
80 Kernel k;
81 {
82 using namespace elementOperators;
83 k << (vecB=generateVEConstant(1.f,2.f));
85 }
86 k.setup();
87 k.compute();
88
90 copy(vecX[0], output);
91
92 bool status(output[1] > 0.09 && output[1] < .1);
94
95 return status;
96}
97
99{
100 cout << "Test of \"System Solve congugate gradient method\" function..." << flush;
101
106
107 auto matA(generateMEConstant(makeAMatr(makeAVec(4.,1.),makeAVec(1.,3.))));
108
109 Kernel k;
110 {
111 using namespace elementOperators;
112 k << (vecB=generateVEConstant(1.f,2.f));
114 }
115 k.setup();
116 k.compute();
117
119 copy(vecX[0], output);
120
121 bool status(output[1] > 0.09 && output[1] < .1);
123
124 return status;
125}
126
127
Matrices.
OpenCl Kernel generator.
Definition aclKernel.h:49
void setup()
void compute()
The class represents several Element.
vector< Element > gcSolveSystemCG(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
vector< Element > gcSolveSystem(const MatrixOfElements &a, const VectorOfElements &b, const VectorOfElements &x)
generates code for solving the solution of a system of linear equations
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
MatrixOfElements generateMEConstant(const asl::AMatr< T > &a)
Generates VectorOfElements correspondinng to a.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
Advanced Computational Language.
Definition acl.h:41
void copy(MemBlock &source, T *destination)
Advanced Simulation Library.
Definition aslDataInc.h:31
AVec< T > makeAVec(T a1)
STL namespace.
bool testSystemSolve()
bool testMatrixOperations()
bool testSystemSolveCG()
int main()