MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / ToSparseMatrix

Function ToSparseMatrix

comp/hcurlamg.cpp:14–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 // some sparse matrix utilities -> should go to linalg
13
14 shared_ptr<SparseMatrixTM<double>> ToSparseMatrix( const Embedding & e )
15 {
16 auto r = e.GetRange();
17 auto h = e.Height();
18 auto w = e.Width();
19
20 Array<int> cnt(h);
21 cnt = 0;
22 cnt.Range(r) = 1;
23
24 shared_ptr<SparseMatrixTM<double>> sp_mat;
25 if(e.IsComplex())
26 sp_mat = make_shared<SparseMatrix<double, Complex, Complex>>( cnt, w );
27 else
28 sp_mat = make_shared<SparseMatrix<double, double, double>>( cnt, w );
29
30 auto & mat = *sp_mat;
31
32 for(auto i : Range(r.Size()))
33 mat(r[i], i) = 1.0;
34
35 return sp_mat;
36 }
37
38 shared_ptr<SparseMatrixTM<double>> ToSparseMatrix( const EmbeddingTranspose & e )
39 {

Callers 1

BuildCoarsePrecondMethod · 0.85

Calls 7

RangeFunction · 0.50
GetRangeMethod · 0.45
HeightMethod · 0.45
WidthMethod · 0.45
RangeMethod · 0.45
IsComplexMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected