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

Method MultiMult

linalg/cg.cpp:133–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131
132 template <class IPTYPE>
133 void CGSolver<IPTYPE> :: MultiMult (const BaseVector & f, BaseVector & u, const int dim) const
134 {
135 try
136 {
137 // Solve A u = f
138 BaseStatusHandler::SetThreadPercentage(0);
139
140 auto d = f.CreateVector();
141 auto w = f.CreateVector();
142 auto s = f.CreateVector();
143
144 int n = 0;
145 Vector<SCAL> al(dim), be(dim), wd(dim), wdn(dim), kss(dim);
146 double err;
147
148 if (initialize)
149 {
150 u = 0.0;
151 d = f;
152 }
153 else
154 {
155 d = f - (*a) * u;
156 }
157 if (c)
158 w = (*c) * d;
159 else
160 w = d;
161
162 s = w;
163
164 BruteInnerProduct(w,d,wdn);
165
166 if (printrates) cout << IM(1) << "0 " << sqrt(L2Norm(wdn)) << endl;
167 if (L2Norm(wdn) == 0.0) wdn = 1;
168
169 if(stop_absolute)
170 err = prec * prec;
171 else
172 err = prec * prec * L2Norm (wdn);
173
174 double lwstart = log(L2Norm(wdn));
175 double lerr = log(err);
176
177
178 while (n++ < maxsteps && L2Norm(wdn) > err && !(BaseStatusHandler::ShouldTerminate()))
179 {
180 w = (*a) * s;
181
182 wd = wdn;
183
184 BruteInnerProduct(s,w,kss);
185
186 //(*testout) << "INNERPROD kss " <<kss << endl;
187 if (L2Norm(kss) == 0.0) break;
188
189 for(int i = 0; i<dim; i++)
190 al[i] = wd[i] / kss[i];

Callers

nothing calls this directly

Calls 9

BruteInnerProductFunction · 0.85
IMClass · 0.85
MemoryMethod · 0.80
L2NormFunction · 0.70
sqrtFunction · 0.50
logFunction · 0.50
CreateVectorMethod · 0.45
SizeMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected