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

◆ koszul() [2/2]

Matrix * Matrix::koszul ( int p) const

Definition at line 1087 of file matrix.cpp.

1088{
1089 if (n_rows() != 1)
1090 {
1091 ERROR("expected a matrix with one row");
1092 return nullptr;
1093 }
1094
1095 FreeModule *F = cols()->exterior(p - 1);
1096 FreeModule *G = cols()->exterior(p);
1097 const Ring *R = get_ring();
1098 MatrixConstructor mat(F, G, degree_shift());
1099 if (p <= 0 || p > n_cols()) return mat.to_matrix();
1100
1101 Subsets C(n_cols(), p);
1102 Subset a(p, 0);
1103 for (int c = 0; c < G->rank(); c++)
1104 {
1105 C.decode(c, a);
1106 int negate = ((p % 2) != 0);
1107 for (int r = p - 1; r >= 0; r--)
1108 {
1109 negate = !negate;
1110 size_t x = C.encodeBoundary(r, a);
1111 ring_elem f = elem(0, static_cast<int>(a[r]));
1112 if (negate) R->negate_to(f);
1113
1114 mat.set_entry(static_cast<int>(x), c, f);
1115 }
1116 }
1117 return mat.to_matrix();
1118}
FreeModule * exterior(int p) const
Definition freemod.cpp:296
friend class FreeModule
Definition matrix.hpp:73
const_monomial degree_shift() const
Definition matrix.hpp:149
const Ring * get_ring() const
Definition matrix.hpp:134
ring_elem elem(int i, int j) const
Definition matrix.cpp:307
friend class MatrixConstructor
Definition matrix.hpp:76
int n_cols() const
Definition matrix.hpp:147
int n_rows() const
Definition matrix.hpp:146
const FreeModule * cols() const
Definition matrix.hpp:145
void negate_to(ring_elem &f) const
Definition ring.cpp:210
std::vector< size_t > Subset
Definition comb.hpp:58
int p
const int ERROR
Definition m2-mem.cpp:55
mpreal & negate(mpreal &x)
Definition mpreal.h:2047
volatile int x
tbb::flow::graph G

References cols(), Subsets::decode(), degree_shift(), elem(), Subsets::encodeBoundary(), ERROR, FreeModule, G, get_ring(), koszul(), Matrix(), MatrixConstructor, n_cols(), n_rows(), Ring::negate_to(), p, MatrixConstructor::set_entry(), MatrixConstructor::to_matrix(), and x.

Referenced by IM2_Matrix_koszul(), koszul(), and koszul().