Macaulay2 Engine
Loading...
Searching...
No Matches

◆ denseToSparse() [1/2]

template<typename RingType>
void ConcreteVectorArithmetic< RingType >::denseToSparse ( ElementArray & dense,
ElementArray & sparse,
int *& comps,
int first,
int last ) const
inline

Definition at line 353 of file VectorArithmetic.hpp.

358 {
359 auto& dvec = * elementArray(dense);
360
361 int len = 0;
362
363 // first can be -1 if the row is zero. in this case, we should
364 // not be accessing dense[i] for i negative.
365 for (int i = first; i >= 0 and i <= last; i++)
366 if (not mRing->is_zero(dvec[i])) len++;
367
368 //comps = f4Vec.allocate(len);
369 comps = new int[len];
370
372 auto& svec = * elementArray(sparse);
373
374 int next = 0;
375 for (int i = first; i >= 0 and i <= last; i++)
376 if (not mRing->is_zero(dvec[i]))
377 {
378 mRing->set(svec[next],dvec[i]);
379 comps[next] = i;
380 ++next;
381 mRing->set_zero(dvec[i]);
382 }
383 }
ElementArrayContainer * elementArray(const ElementArray &f) const
ElementArray allocateElementArray() const

References allocateElementArray(), dvec(), elementArray(), and mRing.