Macaulay2 Engine
Loading...
Searching...
No Matches
BasicPolyList.cpp
Go to the documentation of this file.
1#include "BasicPolyList.hpp"
2#include "matrix.hpp"
3#include "matrix-stream.hpp"
4#include <sstream>
5const Matrix* toMatrix(const FreeModule *target, const BasicPolyList& Fs)
6{
7 MatrixStream S(target);
8 toStream(Fs, S);
9 return S.value();
10}
11
13{
14 mValue.clear();
15 mCurrentPoly = -1;
16 mValue.resize(polyCount);
17}
18
20{
22 mCurrentTerm = -1;
23 mValue[mCurrentPoly].mCoefficients.resize(termCount);
24 mValue[mCurrentPoly].mComponents.resize(termCount);
25 // We don't know the size of the monomial array yet.
26}
27
29{
31 mValue[mCurrentPoly].mComponents[mCurrentTerm] = com;
32 mSizeEntryInMonomial = mValue[mCurrentPoly].mMonomials.size();
33 mValue[mCurrentPoly].mMonomials.push_back(1);
34}
35
37{
38 mValue[mCurrentPoly].mMonomials.push_back(index);
39 mValue[mCurrentPoly].mMonomials.push_back(exponent);
41}
42
44{
45 mValue[mCurrentPoly].mCoefficients[mCurrentTerm] = coefficient;
46}
47
49{
50 if (mCurrentTerm != mValue[mCurrentPoly].mComponents.size() - 1)
51 throw exc::engine_error("internal error: building PolyList from stream has incorrect number of terms in a polynomial");
52}
53
55{
56 if (mCurrentPoly != mValue.size() - 1)
57 throw exc::engine_error("internal error: building PolyList from stream has incorrect number of polynomials");
58}
59
60// TODO: output components too
61
62
64{
65 long result = sizeof(BasicPolyList);
66 for (auto& f : F)
67 result += f.bytesUsed();
68 return result;
69}
70
71
72// Local Variables:
73// indent-tabs-mode: nil
74// End:
long bytesUsed(const BasicPolyList &F)
const Matrix * toMatrix(const FreeModule *target, const BasicPolyList &Fs)
std::vector< BasicPoly > BasicPolyList
void toStream(const BasicPolyList &Fs, S &str)
Ring-agnostic polynomial-list transport type plus its streaming collector and emitter.
void appendTermDone(const Coefficient &coefficient)
void idealBegin(size_t polyCount)
void appendExponent(VarIndex index, Exponent exponent)
void appendPolynomialBegin(size_t termCount)
void appendTermBegin(Component com)
Engine-side free module R^n over a Ring.
Definition freemod.hpp:66
const Matrix * value() const
Streaming consumer that builds an engine Matrix from the mathicgb-style stream callbacks (idealBegin ...
int * exponent
Definition exptable.h:34
#define Matrix
Definition factory.cpp:14
VALGRIND_MAKE_MEM_DEFINED & result(result)
MatrixStream — term-by-term streaming construction of a Matrix.
Matrix — the engine's immutable homomorphism F -> G between free modules.