MCPcopy Create free account
hub / github.com/clMathLibraries/clSPARSE / test_cg

Method test_cg

src/tests/test-solvers.cpp:123–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 }
122
123 void test_cg()
124 {
125
126 if ( typeid(T) == typeid(cl_float) )
127 {
128 clsparseStatus status =
129 clsparseScsrcg(&gX, &CSRE::csrSMatrix, &gB, solverControl, CLSE::control);
130 ASSERT_EQ(clsparseSuccess, status);
131
132// std::cout << "Running CPU Solver" << std::endl;
133// std::shared_ptr<Preconditioner<CSRE::sMatrixType, uBLAS::vector<T>> > ublas_precond;
134
135// if (precond == DIAGONAL )
136// {
137// ublas_precond = std::shared_ptr<Preconditioner<CSRE::sMatrixType, uBLAS::vector<T>> >
138// (new DiagonalPreconditioner<CSRE::sMatrixType, uBLAS::vector<T>> (CSRE::ublasSCsr));
139// }
140// else
141// {
142// ublas_precond = std::shared_ptr<Preconditioner<CSRE::sMatrixType, uBLAS::vector<T>> >
143// (new IdentityPreconditioner<CSRE::sMatrixType, uBLAS::vector<T>> (CSRE::ublasSCsr));
144// }
145
146// size_t iters = pcg_solve(CSRE::ublasSCsr, hX, hB, *ublas_precond,
147// maxIterations, relativeTolerance, absoluteTolerance);
148
149// double ublas_final_residual =
150// uBLAS::norm_2(prod( CSRE::ublasSCsr, hX) - hB) / uBLAS::norm_2(hB);
151
152// std::cout << "uBLAS Solver finished calculations" << std::endl;
153// std::cout << "\tfinal residual = " << ublas_final_residual
154// << "\titerations = " << iters << std::endl;
155
156 }
157
158 if ( typeid(T) == typeid(cl_double))
159 {
160 clsparseStatus status =
161 clsparseDcsrcg(&gX, &CSRE::csrDMatrix, &gB, solverControl, CLSE::control);
162 ASSERT_EQ(clsparseSuccess, status);
163
164// std::cout << "Running CPU Solver" << std::endl;
165// std::shared_ptr<Preconditioner<CSRE::dMatrixType, uBLAS::vector<T>> > ublas_precond;
166
167// if (precond == DIAGONAL )
168// {
169// ublas_precond = std::shared_ptr<Preconditioner<CSRE::dMatrixType, uBLAS::vector<T>> >
170// (new DiagonalPreconditioner<CSRE::dMatrixType, uBLAS::vector<T>> (CSRE::ublasDCsr));
171// }
172// else
173// {
174// ublas_precond = std::shared_ptr<Preconditioner<CSRE::dMatrixType, uBLAS::vector<T>> >
175// (new IdentityPreconditioner<CSRE::dMatrixType, uBLAS::vector<T>> (CSRE::ublasDCsr));
176// }
177
178// size_t iters = pcg_solve(CSRE::ublasDCsr, hX, hB, *ublas_precond,
179// maxIterations, relativeTolerance, absoluteTolerance);
180

Callers 1

TYPED_TESTFunction · 0.80

Calls 2

clsparseScsrcgFunction · 0.85
clsparseDcsrcgFunction · 0.85

Tested by

no test coverage detected