MCPcopy Create free account
hub / github.com/bgrimstad/splinter / computeBasisFunctionMatrix

Method computeBasisFunctionMatrix

src/bsplinebuilder.cpp:166–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166SparseMatrix BSpline::Builder::computeBasisFunctionMatrix(const BSpline &bspline) const
167{
168 unsigned int numVariables = _data.getNumVariables();
169 unsigned int numSamples = _data.getNumSamples();
170
171 // TODO: Reserve nnz per row (degree+1)
172 //int nnzPrCol = bspline.basis.supportedPrInterval();
173
174 SparseMatrix A(numSamples, bspline.getNumBasisFunctions());
175 //A.reserve(DenseVector::Constant(numSamples, nnzPrCol)); // TODO: should reserve nnz per row!
176
177 int i = 0;
178 for (auto it = _data.cbegin(); it != _data.cend(); ++it, ++i)
179 {
180 DenseVector xi(numVariables);
181 xi.setZero();
182 std::vector<double> xv = it->getX();
183 for (unsigned int j = 0; j < numVariables; ++j)
184 {
185 xi(j) = xv.at(j);
186 }
187
188 SparseVector basisValues = bspline.evalBasis(xi);
189
190 for (SparseVector::InnerIterator it2(basisValues); it2; ++it2)
191 {
192 A.insert(i,it2.index()) = it2.value();
193 }
194 }
195
196 A.makeCompressed();
197
198 return A;
199}
200
201DenseVector BSpline::Builder::getSamplePointValues() const
202{

Callers

nothing calls this directly

Calls 5

cbeginMethod · 0.80
cendMethod · 0.80
getXMethod · 0.80
evalBasisMethod · 0.80
getNumBasisFunctionsMethod · 0.45

Tested by

no test coverage detected