40#ifndef HEADER_TRANSFORM
41#define HEADER_TRANSFORM
51template<
typename TYPE1,
typename TYPE2>
54 throw std::runtime_error(
"Error in transform_matrix_from_to : it is not implemented for given template parameters.");
84#ifdef USE_CHUNKS_AND_TASKS
91template<
typename MatrixType,
typename MatrixTypeWrapper>
92inline void get_sparse_matrix_data(
const MatrixType& X,
93 std::vector<int>&
rows,
94 std::vector<int>&
cols,
95 std::vector<real>& vals)
97 throw std::runtime_error(
"Error in transform.h : get_sparse_matrix_data is not implemented for a given template parameters.");
102inline void get_sparse_matrix_data<symmMatrix, chtml::CHTSymmMatrix<real, ParamsType> >(
const symmMatrix& X,
103 std::vector<int>&
rows,
104 std::vector<int>&
cols,
105 std::vector<real>& vals)
113 for (
size_t i = 0; i <
rows.size(); ++i)
121 vals[count] = vals[i];
132inline void get_sparse_matrix_data<symmMatrix, chtml::CHTGeneralMatrix<real, ParamsType> >(
const symmMatrix& X,
133 std::vector<int>&
rows,
134 std::vector<int>&
cols,
135 std::vector<real>& vals)
143 for (
size_t i = 0; i <
rows.size(); ++i)
151 vals[count] = vals[i];
162 rows.reserve(count * 2);
163 cols.reserve(count * 2);
164 vals.reserve(count * 2);
166 size_t N =
rows.size();
167 for (
size_t i = 0; i < N; ++i)
173 vals.push_back(vals[i]);
181inline void get_sparse_matrix_data<triangMatrix, chtml::CHTTriangMatrix<real, ParamsType> >(
const triangMatrix& X,
182 std::vector<int>&
rows,
183 std::vector<int>&
cols,
184 std::vector<real>& vals)
192 for (
size_t i = 0; i <
rows.size(); ++i)
200 vals[count] = vals[i];
211inline void get_sparse_matrix_data<normalMatrix, chtml::CHTGeneralMatrix<real, ParamsType> >(
const normalMatrix& X,
212 std::vector<int>&
rows,
213 std::vector<int>&
cols,
214 std::vector<real>& vals)
222 for (
size_t i = 0; i <
rows.size(); ++i)
230 vals[count] = vals[i];
244 B.set_matrix_params(P);
246 int n =
A.get_nrows();
247 int m =
A.get_ncols();
250 std::vector<int>
rows;
251 std::vector<int>
cols;
252 std::vector<real> vals;
253 get_sparse_matrix_data<symmMatrix, chtml::CHTSymmMatrix<real, ParamsType> >(
A,
rows,
cols, vals);
254 B.create_CHT_matrix_from_sparse(
rows,
cols, vals);
262 B.set_matrix_params(P);
264 int n =
A.get_nrows();
265 int m =
A.get_ncols();
268 std::vector<int>
rows;
269 std::vector<int>
cols;
270 std::vector<real> vals;
271 get_sparse_matrix_data<symmMatrix, chtml::CHTGeneralMatrix<real, ParamsType> >(
A,
rows,
cols, vals);
272 B.create_CHT_matrix_from_sparse(
rows,
cols, vals);
280 B.set_matrix_params(P);
282 int n =
A.get_nrows();
283 int m =
A.get_ncols();
286 std::vector<int>
rows;
287 std::vector<int>
cols;
288 std::vector<real> vals;
289 get_sparse_matrix_data<normalMatrix, chtml::CHTGeneralMatrix<real, ParamsType> >(
A,
rows,
cols, vals);
290 B.create_CHT_matrix_from_sparse(
rows,
cols, vals);
298 B.set_matrix_params(P);
300 int n =
A.get_nrows();
301 int m =
A.get_ncols();
304 std::vector<int>
rows;
305 std::vector<int>
cols;
306 std::vector<real> vals;
307 get_sparse_matrix_data<triangMatrix, chtml::CHTTriangMatrix<real, ParamsType> >(
A,
rows,
cols, vals);
308 B.create_CHT_matrix_from_sparse(
rows,
cols, vals);
315template<
typename MatrixTypeCHT,
typename MatrixType>
316inline void set_sparse_matrix_from_data(
MatrixType& X,
317 const std::vector<int>&
rows,
318 const std::vector<int>&
cols,
319 const std::vector<real>& vals)
321 throw std::runtime_error(
"Error in transform_matrix_from_to : set_sparse_matrix_from_data is not implemented for a given template parameters.");
326inline void set_sparse_matrix_from_data<chtml::CHTGeneralMatrix<real, ParamsType>,
symmMatrix>(
symmMatrix&
A,
327 const std::vector<int>&
rows,
328 const std::vector<int>&
cols,
329 const std::vector<real>& vals)
332 std::vector<int> rows1;
333 rows1.resize(
rows.size());
334 std::vector<int> cols1;
335 cols1.resize(
cols.size());
336 std::vector<real> vals1;
337 vals1.resize(vals.size());
339 for (
size_t i = 0; i <
rows.size(); ++i)
345 rows1[count] =
rows[i];
346 cols1[count] =
cols[i];
347 vals1[count] = vals[i];
353 A.assign_from_sparse(rows1, cols1, vals1);
358inline void set_sparse_matrix_from_data<chtml::CHTSymmMatrix<real, ParamsType>,
symmMatrix>(
symmMatrix&
A,
359 const std::vector<int>&
rows,
360 const std::vector<int>&
cols,
361 const std::vector<real>& vals)
373 std::vector<int>
rows;
374 std::vector<int>
cols;
375 std::vector<real> vals;
384 set_sparse_matrix_from_data<chtml::CHTSymmMatrix<real, ParamsType>,
symmMatrix>(
B,
rows,
cols, vals);
394 std::vector<int>
rows;
395 std::vector<int>
cols;
396 std::vector<real> vals;
405 set_sparse_matrix_from_data<chtml::CHTGeneralMatrix<real, ParamsType>,
symmMatrix>(
B,
rows,
cols, vals);
Definition matrix_typedefs_chtml.h:79
Symmetric matrix.
Definition MatrixSymmetric.h:68
mat::SizesAndBlocks rows
Definition test.cc:51
mat::SizesAndBlocks cols
Definition test.cc:52
ergo_real real
Definition test.cc:46
Header file with typedefs for matrix and vector types.
Header file with typedefs for matrix types, using either the hierarchical matrix library (HML) or the...
double ergo_real
Definition realtype.h:69
MatrixSymmetric< real, matri > symmMatrix
Definition test_LanczosSeveralLargestEig.cc:69
MatrixTriangular< real, matri > triangMatrix
Definition test_LanczosSeveralLargestEig.cc:70
MatrixGeneral< real, matri > normalMatrix
Definition test_LanczosSeveralLargestEig.cc:71