Macaulay2 Engine
Loading...
Searching...
No Matches
matrix.cpp
Go to the documentation of this file.
1// Copyright 1995 Michael E. Stillman
2
3#include "interface/matrix.h"
4
5#include <M2/math-include.h>
6
7#include "NAG.hpp" // TODO: can this be removed?
8#include "SLP-defs.hpp"
9#include "buffer.hpp"
10#include "dmat.hpp"
11#include "error.h"
12#include "exceptions.hpp"
13#include "freemod.hpp"
14#include "interface/NAG.h"
15#include "interface/gmp-util.h"
16#include "interface/monoid.h"
17#include "mat.hpp"
18#include "matrix-con.hpp"
19#include "matrix.hpp"
20#include "mutablemat-defs.hpp"
21#include "relem.hpp"
22#include "ring.hpp"
23#include "ringelem.hpp"
24#include "BasicPolyList.hpp"
26//#include "matrix-io.hpp"
27
28namespace M2 { class ARingCC; }
29
30const FreeModule *IM2_Matrix_get_target(const Matrix *M) { return M->rows(); }
31const FreeModule *IM2_Matrix_get_source(const Matrix *M) { return M->cols(); }
32int IM2_Matrix_n_rows(const Matrix *M) { return M->n_rows(); }
33int IM2_Matrix_n_cols(const Matrix *M) { return M->n_cols(); }
34
39
40M2_string IM2_Matrix_to_string(const Matrix *M)
41{
42 buffer o;
43 try
44 {
45 M->text_out(o);
46 return o.to_string();
47 } catch (const exc::engine_error& e)
48 {
49 o << "[unprintable matrix]";
50 return o.to_string();
51 }
52}
53
54unsigned int rawMatrixHash(const Matrix *M) { return M->hash(); }
55const RingElement /* or null */ *IM2_Matrix_get_entry(const Matrix *M,
56 int r,
57 int c)
58{
59 try
60 {
61 if (r < 0 || r >= M->n_rows())
62 {
63 ERROR("matrix row index %d out of range 0 .. %d", r, M->n_rows() - 1);
64 return nullptr;
65 }
66 if (c < 0 || c >= M->n_cols())
67 {
68 ERROR("matrix column index %d out of range 0 .. %d",
69 c,
70 M->n_cols() - 1);
71 return nullptr;
72 }
74 result = M->elem(r, c);
76 } catch (const exc::engine_error& e)
77 {
78 ERROR(e.what());
79 return nullptr;
80 }
81}
82
83/* Returns the entries of the matrix in a flat array in row major order
84 */
86{
87 try
88 {
89 int ncols = M->n_cols();
90 int nrows = M->n_rows();
91 if(nrows < 0 || ncols < 0)
92 {
93 ERROR("internal error: matrix has a negative size %d by %d",
94 nrows,
95 ncols);
96 return nullptr;
97 }
98 engine_RawRingElementArrayArray entries =
99 getmemarraytype(engine_RawRingElementArrayArray, nrows);
100 entries->len = nrows;
103 for(int r = 0; r < nrows; r++)
104 {
105 engine_RawRingElementArray currRow =
106 getmemarraytype(engine_RawRingElementArray, ncols);
107 currRow->len = ncols;
108 std::fill_n(currRow->array, ncols, zero);
109 entries->array[r] = currRow;
110 }
111 //walk through the columns
112 for(int c = 0; c < ncols; c++)
113 {
114 const vec &column = M->elem(c);
115 for(const vecterm &term : column)
116 {
117 if(term.comp < 0 || term.comp >= nrows)
118 {
119 ERROR("internal error: matrix contains invalid entries:"
120 "row index %d out of range 0 .. %d",
121 term.comp,
122 nrows - 1);
123 //Ignoring the entry and continuing
124 continue;
125 }
126 entries->array[term.comp]->array[c] =
127 RingElement::make_raw(M->get_ring(), term.coeff);
128 }
129 }
130 return entries;
131 } catch (const exc::engine_error &e)
132 {
133 ERROR(e.what());
134 return nullptr;
135 }
136 return nullptr;
137}
138
139const Matrix *IM2_Matrix_identity(const FreeModule *F, int preference)
140{
141 (void) preference;
142#ifdef DEVELOPMENT
143#warning prefer_dense not yet used
144#endif
145 return Matrix::identity(F);
146}
147
148const Matrix /* or null */ *IM2_Matrix_zero(const FreeModule *F,
149 const FreeModule *G,
150 int preference)
151{
152 (void) preference;
153#ifdef DEVELOPMENT
154#warning prefer_dense not yet used
155#endif
156 return Matrix::zero(F, G);
157}
158
159const Matrix /* or null */ *IM2_Matrix_make1(const FreeModule *target,
160 int ncols,
161 const engine_RawRingElementArray M,
162 int preference)
163{
164 (void) preference;
165#ifdef DEVELOPMENT
166#warning prefer_dense not yet used
167#endif
168 return Matrix::make(target, ncols, M);
169}
170
171const Matrix /* or null */ *IM2_Matrix_make2(const FreeModule *target,
172 const FreeModule *source,
173 M2_arrayint deg,
174 const engine_RawRingElementArray M,
175 int preference)
176{
177 (void) preference;
178#ifdef DEVELOPMENT
179#warning prefer_dense not yet used
180#endif
181 return Matrix::make(target, source, deg, M);
182}
183
184const Matrix /* or null */ *IM2_Matrix_make_sparse1(
185 const FreeModule *target,
186 int ncols,
187 M2_arrayint rows,
188 M2_arrayint cols,
189 const engine_RawRingElementArray entries,
190 int preference)
191{
192 (void) preference;
193#ifdef DEVELOPMENT
194#warning prefer_dense not yet used
195#endif
196 return Matrix::make_sparse(target, ncols, rows, cols, entries);
197}
198
199const Matrix /* or null */ *IM2_Matrix_make_sparse2(
200 const FreeModule *target,
201 const FreeModule *source,
202 M2_arrayint deg,
203 M2_arrayint rows,
204 M2_arrayint cols,
205 const engine_RawRingElementArray entries,
206 int preference)
207{
208 (void) preference;
209#ifdef DEVELOPMENT
210#warning prefer_dense not yet used
211#endif
212 return Matrix::make_sparse(target, source, deg, rows, cols, entries);
213}
214
216/* Is the matrix M implemented as dense? */
217{
218 (void) M;
219#ifdef DEVELOPMENT
220#warning not implemented yet
221#endif
222 return 0;
223}
224
225const Matrix /* or null */ *IM2_Matrix_remake2(const FreeModule *target,
226 const FreeModule *source,
227 M2_arrayint deg,
228 const Matrix *M,
229 int preference)
230/* Create a new matrix (mutable or immutable), from M, with new target,
231 source, deg and/or mutable-ness. The new free modules must have
232 the expected rank.
233*/
234{
235 (void) preference;
236#ifdef DEVELOPMENT
237#warning prefer_dense not yet used
238#endif
239 return M->remake(target, source, deg);
240}
241
242const Matrix /* or null */ *IM2_Matrix_remake1(const FreeModule *target,
243 const Matrix *M,
244 int preference)
245/* Create a new matrix, from M, with new target,
246 The target free module must have the expected rank.
247 The source free module is computed heuristically from the target and the
248 columns of the matrix.
249*/
250{
251 (void) preference;
252 try
253 {
254#ifdef DEVELOPMENT
255#warning prefer_dense not yet used
256#endif
257 return M->remake(target);
258 } catch (const exc::engine_error& e)
259 {
260 ERROR(e.what());
261 return nullptr;
262 }
263}
264
265const Matrix /* or null */ *IM2_Matrix_random(
266 const Ring *R,
267 int r,
268 int c,
269 double fraction_non_zero,
270 int special_type, // 0: general, 1:upper triangular, others?
271 int preference)
272{
273 (void) preference;
274#ifdef DEVELOPMENT
275#warning preference not yet used
276#endif
277 return Matrix::random(R, r, c, fraction_non_zero, special_type);
278}
279
280const Matrix* /* or null */ rawMatrixReadMsolveString(const Ring* R, M2_string contents)
281{
282 try
283 {
284 std::string str = string_M2_to_std(contents);// TODO: this does a full copy. Perhaps we just have readMsolveIdealContents take a string_view?
285 auto Fs = parseMsolveFromString(str);
286 return toMatrix(R->make_FreeModule(1), Fs);
287 } catch (const exc::engine_error& e)
288 {
289 ERROR(e.what());
290 return nullptr;
291 }
292}
293
294const Matrix* /* or null */ rawMatrixReadMsolveFile(const Ring* R, M2_string filename)
295{
296 try
297 {
298 std::string str = string_M2_to_std(filename);
299 auto Fs = parseMsolveFile(str);
300 return toMatrix(R->make_FreeModule(1), Fs);
301 } catch (const exc::engine_error& e)
302 {
303 ERROR(e.what());
304 return nullptr;
305 }
306}
307
309M2_bool IM2_Matrix_is_zero(const Matrix *M) { return M->is_zero(); }
310int // 1 = true, 0 = false, -1 = error
312{
313 try
314 {
315 /* This checks that the entries of M,N are the same, as well as
316 that the source and target are the same (as graded free modules).
317 Therefore, it can happen that M-N == 0, but M != N.
318 */
319 return M->is_equal(*N);
320 } catch (const exc::engine_error& e)
321 {
322 ERROR(e.what());
323 return -1;
324 }
325}
326
328const Matrix /* or null */ *IM2_Matrix_concat(const engine_RawMatrixArray Ms)
329{
330 try
331 {
332 unsigned int n = Ms->len;
333 if (n == 0)
334 {
335 ERROR("matrix concat: expects at least one matrix");
336 return nullptr;
337 }
338 const FreeModule *F = Ms->array[0]->rows();
339 const Ring *R = F->get_ring();
340 MatrixConstructor mat(Ms->array[0]->rows(), 0);
341 int next = 0;
342 for (unsigned int i = 0; i < n; i++)
343 {
344 const Matrix *M = Ms->array[i];
345 if (R != M->get_ring())
346 {
347 ERROR("matrix concat: different base rings");
348 return nullptr;
349 }
350 if (F->rank() != M->n_rows())
351 {
352 ERROR("matrix concat: row sizes are not equal");
353 return nullptr;
354 }
355 for (int j = 0; j < M->n_cols(); j++)
356 {
357 mat.append(R->copy_vec(M->elem(j)));
358 mat.set_column_degree(next++, M->cols()->degree(j));
359 }
360 }
361 return mat.to_matrix();
362 } catch (const exc::engine_error& e)
363 {
364 ERROR(e.what());
365 return nullptr;
366 }
367}
368
369const Matrix /* or null */ *IM2_Matrix_direct_sum(
370 const engine_RawMatrixArray Ms)
371{
372 try
373 {
374 // Check that the matrices all have the same ring, and that there is
375 // at least one matrix.
376 unsigned int n = Ms->len;
377 if (n == 0)
378 {
379 ERROR("matrix direct sum: expects at least one matrix");
380 return nullptr;
381 }
382 const Matrix *result = Ms->array[0];
383 const Ring *R = result->get_ring();
384 for (unsigned int i = 1; i < n; i++)
385 if (R != Ms->array[i]->get_ring())
386 {
387 ERROR("matrix direct sum: different base rings");
388 return nullptr;
389 }
390 for (unsigned int i = 1; i < n; i++)
391 result = result->direct_sum(Ms->array[i]);
392
393 return result;
394 } catch (const exc::engine_error& e)
395 {
396 ERROR(e.what());
397 return nullptr;
398 }
399}
400
401const Matrix /* or null */ *IM2_Matrix_tensor(const Matrix *M, const Matrix *N)
402{
403 try
404 {
405 return M->tensor(N);
406 } catch (const exc::engine_error& e)
407 {
408 ERROR(e.what());
409 return nullptr;
410 }
411}
412
413const Matrix /* or null */ *rawModuleTensor(const Matrix *M, const Matrix *N)
414{
415 try
416 {
417 return M->module_tensor(N);
418 } catch (const exc::engine_error& e)
419 {
420 ERROR(e.what());
421 return nullptr;
422 }
423}
424
425const Matrix /* or null */ *IM2_Matrix_transpose(const Matrix *M)
426{
427 try
428 {
429 return M->transpose();
430 } catch (const exc::engine_error& e)
431 {
432 ERROR(e.what());
433 return nullptr;
434 }
435}
436
437const Matrix /* or null */ *IM2_Matrix_reshape(const Matrix *M,
438 const FreeModule *F,
439 const FreeModule *G)
440{
441 try
442 {
443 return M->reshape(F, G);
444 } catch (const exc::engine_error& e)
445 {
446 ERROR(e.what());
447 return nullptr;
448 }
449}
450
451const Matrix /* or null */ *IM2_Matrix_flip(const FreeModule *F,
452 const FreeModule *G)
453{
454 try
455 {
456 return Matrix::flip(F, G);
457 } catch (const exc::engine_error& e)
458 {
459 ERROR(e.what());
460 return nullptr;
461 }
462}
463
464const Matrix /* or null */ *rawWedgeProduct(int p, int q, const FreeModule *F)
465/* Constructs the map
466 exterior(p,F) ** exterior(q,F) --> exterior(p+q,F)
467*/
468{
469 try
470 {
471 return Matrix::wedge_product(p, q, F);
472 } catch (const exc::engine_error& e)
473 {
474 ERROR(e.what());
475 return nullptr;
476 }
477}
478
479const Matrix /* or null */ *IM2_Matrix_submatrix(const Matrix *M,
480 M2_arrayint rows,
481 M2_arrayint cols)
482{
483 try
484 {
485 return M->sub_matrix(rows, cols);
486 } catch (const exc::engine_error& e)
487 {
488 ERROR(e.what());
489 return nullptr;
490 }
491}
492
493const Matrix /* or null */ *IM2_Matrix_submatrix1(const Matrix *M,
494 M2_arrayint cols)
495{
496 try
497 {
498 return M->sub_matrix(cols);
499 } catch (const exc::engine_error& e)
500 {
501 ERROR(e.what());
502 return nullptr;
503 }
504}
505
506const Matrix /* or null */ *IM2_Matrix_koszul(int p, const Matrix *M)
507{
508 try
509 {
510 return M->koszul(p);
511 } catch (const exc::engine_error& e)
512 {
513 ERROR(e.what());
514 return nullptr;
515 }
516}
517
518const Matrix /* or null */ *rawKoszulMonomials(int nskew,
519 const Matrix *M,
520 const Matrix *N)
521{
522 try
523 {
524#ifdef DEVELOPMENT
525#warning "check with 0.9.2 about what this should even do"
526#endif
527 if (M->get_ring() != N->get_ring())
528 {
529 ERROR("expected same ring");
530 return nullptr;
531 }
532 return Matrix::koszul_monomials(nskew, M, N);
533 } catch (const exc::engine_error& e)
534 {
535 ERROR(e.what());
536 return nullptr;
537 }
538}
539
540const Matrix /* or null */ *IM2_Matrix_symm(int p, const Matrix *M)
541{
542 try
543 {
544 return M->symm(p);
545 } catch (const exc::engine_error& e)
546 {
547 ERROR(e.what());
548 return nullptr;
549 }
550}
551
552const Matrix /* or null */ *IM2_Matrix_exterior(int p,
553 const Matrix *M,
554 int strategy)
555{
556 try
557 {
558 return M->exterior(p, strategy);
559 } catch (const exc::engine_error& e)
560 {
561 ERROR(e.what());
562 return nullptr;
563 }
564
565}
566
568 int deg_order,
569 int mon_order)
570{
571 try
572 {
573 return M->sort(deg_order, mon_order);
574 } catch (const exc::engine_error& e)
575 {
576 ERROR(e.what());
577 return nullptr;
578 }
579}
580
581const Matrix /* or null */ *IM2_Matrix_minors(int p,
582 const Matrix *M,
583 int strategy)
584{
585 try
586 {
587 return M->minors(p, strategy);
588 } catch (const exc::engine_error& e)
589 {
590 ERROR(e.what());
591 return nullptr;
592 }
593}
594
595const Matrix /* or null */ *rawMinors(
596 int p,
597 const Matrix *M,
598 int strategy,
599 int n_minors_to_compute, /* -1 means all */
600 M2_arrayintOrNull first_row_set,
601 M2_arrayintOrNull first_col_set)
602/* If first_row_set or first_col_set is not NULL, they should both be non-NULL,
603 and both have length p. If not, NULL is returned.
604 Compute n_minors_to_compute minors, starting at (first_row_set,first_col_set)
605 if given,
606 otherwise starting at the first (0..p-1,0..p-1).
607*/
608{
609 try {
610 return M->minors(
611 p, strategy, n_minors_to_compute,
612 first_row_set, first_col_set);
613 } catch (const exc::engine_error& e)
614 {
615 ERROR(e.what());
616 return nullptr;
617 }
618}
619
620const Matrix /* or null */ *IM2_Matrix_pfaffians(int p, const Matrix *M)
621{
622 return M->pfaffians(p);
623}
624
625const RingElement /* or null */ *IM2_Matrix_pfaffian(const Matrix *M)
626{
627 return RingElement::make_raw(M->get_ring(), M->pfaffian());
628}
629
630const Matrix /* or null */ *IM2_Matrix_diff(const Matrix *M, const Matrix *N)
631{
632 return M->diff(N, 1);
633}
634
635const Matrix /* or null */ *IM2_Matrix_contract(const Matrix *M,
636 const Matrix *N)
637{
638 return M->diff(N, 0);
639}
640
641const Matrix /* or null */ *IM2_Matrix_homogenize(const Matrix *M,
642 int var,
643 M2_arrayint wts)
644{
645 return M->homogenize(var, M2_arrayint_to_stdvector<int>(wts));
646}
647
648const Matrix /* or null */ *rawCoefficients(M2_arrayint vars,
649 const Matrix *monoms,
650 const Matrix *M)
651{
652 return M->coeffs(vars, monoms);
653}
654
655const Matrix /* or null */ *rawBasis(
656 const Matrix *M,
657 M2_arrayint lo_degree, /* possibly length 0 */
658 M2_arrayint hi_degree,
659 M2_arrayint wt,
660 M2_arrayint vars,
661 M2_bool do_truncation,
662 int limit)
663{
664 return M->Matrix::basis(lo_degree, hi_degree, wt, vars, do_truncation, limit);
665}
666
668/* The list of indices of variables which occur in f is returned. */
669/* currently requires a polynomial ring */ { return f->support(); }
670const Matrix /* or null */ *IM2_Matrix_monomials(M2_arrayint vars,
671 const Matrix *M)
672{
673 return M->monomials(vars);
674}
675
676const Matrix *IM2_Matrix_initial(int nparts, const Matrix *M)
677{
678 return M->lead_term(nparts);
679}
680
682{
683 return M->elim_vars(nparts);
684}
685
687{
688 return M->elim_keep(nparts);
689}
690
692{
693 Matrix *coeffs;
694 Matrix *monoms;
695 coeffs = M->top_coefficients(monoms);
696 if (coeffs == nullptr) return nullptr;
697 engine_RawMatrixPair result = new engine_RawMatrixPair_struct;
698 result->a = monoms;
699 result->b = coeffs;
700 return result;
701}
702
704 int var,
705 int maxdegree)
706/* If M = [v1, ..., vn], and x = 'var'th variable in the ring,
707 return the matrix [w1,...,wn], where wi * x^(ai) = vi,
708 and wi is not divisible by x, or ai = maxdegree,
709 and the integer which is the maximum of the ai's.
710 QUESTION: what rings should this work over?
711*/
712{
713 int actualdegree;
714 Matrix *N = M->divide_by_var(var, maxdegree, actualdegree);
715 engine_RawMatrixAndInt result = new engine_RawMatrixAndInt_struct;
716 result->M = N;
717 result->i = actualdegree;
718 return result;
719}
720
721const Matrix *rawMatrixCompress(const Matrix *M) { return M->compress(); }
722
724 M2_bool make_squarefree_only)
725{
726 return m->remove_monomial_factors(make_squarefree_only);
727}
728
730{
731 return m->remove_scalar_multiples();
732}
733
734// See engine.h for our definition of 'content'
735
736const Matrix /* or null */ *rawMatrixContent(const Matrix *M)
737// returns the matrix of the content of each column of M.
738{
739 return M->content();
740}
741
742const Matrix /* or null */ *rawMatrixRemoveContent(const Matrix *M)
743{
744 return M->remove_content();
745}
746
747const Matrix /* or null */ *rawMatrixSplitContent(
748 const Matrix *M,
749 const Matrix /* or null */ **result)
750{
751 return M->split_off_content(*result);
752}
753
754const Matrix /* or null */ *IM2_Matrix_remove_content(const Matrix *M)
755{
756 (void) M;
757#ifdef DEVELOPMENT
758#warning \
759 "const Matrix /* or null */ * IM2_Matrix_remove_content(const Matrix *M) -- not implemented yet"
760#endif
761 return nullptr;
762}
763
764const Matrix /* or null */ *IM2_Matrix_promote(const FreeModule *newTarget,
765 const Matrix *f)
766{
767 try
768 {
769 ring_elem a;
770 const Ring *R = f->get_ring();
771 const Ring *S = newTarget->get_ring();
772 MatrixConstructor mat(newTarget, f->n_cols());
773 Matrix::iterator i(f);
774 for (int c = 0; c < f->n_cols(); c++)
775 for (i.set(c); i.valid(); i.next())
776 if (S->promote(R, i.entry(), a))
777 mat.set_entry(i.row(), c, a);
778 else
779 {
780 ERROR("cannot promote given matrix");
781 return nullptr;
782 }
784 return mat.to_matrix();
785 } catch (const exc::engine_error& e)
786 {
787 ERROR(e.what());
788 return nullptr;
789 }
790}
791
792const Matrix /* or null */ *IM2_Matrix_lift(int *success_return,
793 const FreeModule *newTarget,
794 const Matrix *f)
795{
796 try
797 {
798 ring_elem a;
799 const Ring *R = f->get_ring();
800 const Ring *S = newTarget->get_ring();
801 MatrixConstructor mat(newTarget, f->n_cols());
802 Matrix::iterator i(f);
803 for (int c = 0; c < f->n_cols(); c++)
804 for (i.set(c); i.valid(); i.next())
805 if (R->lift(S, i.entry(), a))
806 mat.set_entry(i.row(), c, a);
807 else
808 {
809 // ERROR("cannot lift given matrix");
810 return nullptr;
811 }
813 *success_return = 1;
814 return mat.to_matrix();
815 } catch (const exc::engine_error& e)
816 {
817 ERROR(e.what());
818 return nullptr;
819 }
820}
821
822gmp_ZZ to_gmp_ZZ(int a) // helper fn!!!
823{
824 mpz_ptr result = getmemstructtype(mpz_ptr);
825 mpz_init(result);
826 mpz_set_si(result, a);
828 return result;
829}
830
832 M2SLEvaluator *Hxt,
833 M2SLEvaluator *HxH)
834{
835 try {
836 return new M2Homotopy(Hx->value().createHomotopy(&(Hxt->value()), &(HxH->value())));
837 } catch (const exc::engine_error& e) {
838 ERROR(e.what());
839 return nullptr;
840 }
841}
842
844 const MutableMatrix *inputs,
845 MutableMatrix *outputs,
846 MutableMatrix *output_extras,
847 gmp_RR init_dt,
848 gmp_RR min_dt,
849 gmp_RR epsilon, // o.CorrectorTolerance,
850 int max_corr_steps,
851 gmp_RR infinity_threshold,
852 M2_bool checkPrecision)
853{
854 try {
855 return H->value().track(inputs,
856 outputs,
857 output_extras,
858 init_dt,
859 min_dt,
860 epsilon, // o.CorrectorTolerance,
861 max_corr_steps,
862 infinity_threshold,
863 checkPrecision);
864 } catch (const exc::engine_error& e) {
865 ERROR(e.what());
866 return false;
867 }
868}
869
871{
872 buffer o;
873 H->value().text_out(o);
874 return o.to_string();
875}
876unsigned int rawHomotopyHash(M2Homotopy *) { return 0; }
878 M2_arrayint constsPos,
879 M2_arrayint varsPos,
880 const MutableMatrix *consts)
881{
882 return consts->createSLEvaluator(SLP, constsPos, varsPos);
883}
884
886 M2_string libName,
887 int nInputs,
888 int nOutputs,
889 const MutableMatrix *empty)
890{
891 return empty->createCompiledSLEvaluator(libName, nInputs, nOutputs);
892}
893
895 M2SLEvaluator *H,
896 const MutableMatrix *parameters)
897{
898 try {
899 return new M2SLEvaluator(H->value().specialize(parameters));
900 } catch (const exc::engine_error& e) {
901 ERROR(e.what());
902 return nullptr;
903 }
904}
905
907 const MutableMatrix *inputs,
908 MutableMatrix *outputs)
909{
910 try {
911 return sle->value().evaluate(inputs, outputs);
912 } catch (const exc::engine_error& e) {
913 ERROR(e.what());
914 return false;
915 }
916}
917
919{
920 buffer o;
921 sle->value().text_out(o);
922 return o.to_string();
923}
924unsigned int rawSLEvaluatorHash(M2SLEvaluator *) { return 0; }
925M2SLProgram /* or null */ *rawSLProgram(unsigned long nConstantsAndInputs)
926{
927 (void) nConstantsAndInputs;
928 return new M2SLProgram(new SLProgram);
929}
931{
932 buffer o;
933 slp->value().text_out(o);
934 return o.to_string();
935}
936unsigned int rawSLProgramHash(M2SLProgram *) { return 0; }
939{
940 return to_gmp_ZZ(S->value().addMSum(a));
941}
947{
948 return to_gmp_ZZ(S->value().addDet(a));
949}
951{
953 return to_gmp_ZZ(0); // this function should have returned "void"
954}
959
960StraightLineProgram /* or null */ *rawSLP(const Matrix *consts,
961 M2_arrayint program)
962{
963 try {
964 return StraightLineProgram::make(consts, program);
965 } catch (const exc::engine_error& e) {
966 ERROR(e.what());
967 return nullptr;
968 }
969}
970
972 const Matrix *vals)
973{
974 try {
975 return SLP->evaluate(vals);
976 } catch (const exc::engine_error& e) {
977 ERROR(e.what());
978 return nullptr;
979 }
980}
981
983{
984 buffer o;
985 slp->text_out(o);
986 return o.to_string();
987}
988
990{
991 return slp->hash();
992}
993
995
997 StraightLineProgram *slp_pred,
998 StraightLineProgram *slp_corr)
999{
1000 try {
1001 return PathTracker::make(slp_pred, slp_corr);
1002 } catch (const exc::engine_error& e) {
1003 ERROR(e.what());
1004 return nullptr;
1005 }
1006}
1007
1008PathTracker /* or null */ *rawPathTracker(const Matrix *HH)
1009{
1010 try {
1011 return PathTracker::make(HH);
1012 } catch (const exc::engine_error& e) {
1013 ERROR(e.what());
1014 return nullptr;
1015 }
1016}
1017
1019 const Matrix *T,
1020 gmp_RR productST)
1021{
1022 try {
1023 return PathTracker::make(S, T, productST);
1024 } catch (const exc::engine_error& e) {
1025 ERROR(e.what());
1026 return nullptr;
1027 }
1028}
1029
1031{
1032 buffer o;
1033 p->text_out(o);
1034 return o.to_string();
1035}
1036
1037unsigned int rawPathTrackerHash(PathTracker *p) { return p->hash(); }
1038// PointArray
1039
1041{
1042 buffer o;
1043 pa->value().text_out(o);
1044 return o.to_string();
1045}
1046
1048{
1049 return pa->hash();
1050}
1051
1052M2PointArray /* or null */ *rawPointArray(double epsilon, int n)
1053{
1054 try {
1055 return new M2PointArray(new PointArray(epsilon, n));
1056 } catch (const exc::engine_error& e) {
1057 ERROR(e.what());
1058 return nullptr;
1059 }
1060}
1061
1063{
1065 auto MC = dynamic_cast<const MutableMat<DMat<M2::ARingCC> > *>(M);
1066 // if (MC == nullptr)
1067 if (MC == nullptr)
1068 {
1069 throw exc::engine_error("expected mutable matrix over CC");
1070 }
1071
1072 for (size_t r = 0; r < MC->getMat().numRows(); ++r)
1073 {
1074 result.push_back(MC->getMat().entry(r, col).re);
1075 result.push_back(MC->getMat().entry(r, col).im);
1076 }
1077 return result;
1078}
1079
1081{
1082 return pa->value().lookup(getRealVector(M, col));
1083}
1084
1086{
1087 return pa->value().lookup_or_append(getRealVector(M, col));
1088}
1089
1090// Local Variables:
1091// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
1092// indent-tabs-mode: nil
1093// End:
const Matrix * toMatrix(const FreeModule *target, const BasicPolyList &Fs)
Ring-agnostic polynomial-list transport type plus its streaming collector and emitter.
BasicPolyList parseMsolveFile(std::string filename)
BasicPolyList parseMsolveFromString(std::string contents)
Parsers from text (string or file) into a BasicPolyList, including the Msolve input format.
Engine-boundary C API for the Numerical Algebraic Geometry subsystem.
Numerical Algebraic Geometry: homotopy continuation PathTracker and supporting numeric types.
Type declarations for the SLP DAG, its evaluator hierarchy, and the homotopy abstraction.
Append-only GC-backed byte buffer used throughout the engine for text output.
unsigned int hash() const
Definition hash.hpp:70
const Ring * get_ring() const
Definition freemod.hpp:102
const_monomial degree(int i) const
Definition freemod.hpp:104
int rank() const
Definition freemod.hpp:105
Engine-side free module R^n over a Ring.
Definition freemod.hpp:66
virtual void text_out(buffer &o) const =0
virtual bool track(const MutableMatrix *inputs, MutableMatrix *outputs, MutableMatrix *output_extras, gmp_RR init_dt, gmp_RR min_dt, gmp_RR epsilon, int max_corr_steps, gmp_RR infinity_threshold, bool checkPrecision)=0
aring-style adapter for double-precision complex numbers, stored as (double, double) pairs.
Definition aring-CC.hpp:72
Homotopy & value()
Definition SLP-defs.hpp:144
MutableEngineObject wrapper that owns a Homotopy via unique_ptr.
Definition SLP-defs.hpp:139
PointArray & value()
Definition NAG.hpp:93
MutableEngineObject wrapper that owns a PointArray via unique_ptr.
Definition NAG.hpp:88
SLEvaluator & value()
Definition SLP-defs.hpp:254
MutableEngineObject wrapper holding a raw SLEvaluator*.
Definition SLP-defs.hpp:248
SLProgram & value()
Definition SLP-defs.hpp:69
MutableEngineObject wrapper that owns an SLProgram via unique_ptr.
Definition SLP-defs.hpp:64
void set(int newcol)
Definition matrix.hpp:312
ring_elem entry()
Definition matrix.hpp:320
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
Matrix * minors(int p, int strategy) const
Definition det.cpp:440
Matrix * remove_monomial_factors(bool make_squarefree_only) const
Definition matrix.cpp:1462
Matrix * top_coefficients(Matrix *&monoms) const
Definition matrix.cpp:994
M2_arrayintOrNull support() const
Definition matrix.cpp:922
const Matrix * remake(const FreeModule *target, const FreeModule *source, M2_arrayint deg) const
Definition matrix.cpp:228
const Matrix * remove_content() const
Definition matrix.cpp:2034
bool is_zero() const
Definition matrix.cpp:325
Matrix * module_tensor(const Matrix *m) const
Definition matrix.cpp:686
Matrix * monomials(M2_arrayint vars) const
Definition matrix.cpp:1699
int n_cols() const
Definition matrix.hpp:147
M2_arrayint elim_keep(int nparts) const
Definition matrix.cpp:1047
int n_rows() const
Definition matrix.hpp:146
bool is_homogeneous() const
Definition matrix.cpp:332
const Matrix * split_off_content(const Matrix *&result) const
Definition matrix.cpp:2043
Matrix * symm(int n) const
Matrix * pfaffians(int p) const
Definition pfaff.cpp:101
Matrix * homogenize(int v, const std::vector< int > &wts) const
Definition matrix.cpp:359
const FreeModule * rows() const
Definition matrix.hpp:144
Matrix * exterior(int p, int strategy) const
Definition det.cpp:425
Matrix * diff(const Matrix *m, int use_coef) const
Definition matrix.cpp:805
Matrix * lead_term(int n=-1) const
Definition matrix.cpp:840
ring_elem pfaffian() const
Definition pfaff.cpp:113
M2_arrayint sort(int degorder, int monorder) const
void text_out(buffer &o) const
Definition matrix.cpp:1316
Matrix * transpose() const
Definition matrix.cpp:566
const FreeModule * cols() const
Definition matrix.hpp:145
Matrix * koszul(int p) const
Definition matrix.cpp:1087
Matrix * tensor(const Matrix *m) const
Definition matrix.cpp:780
Matrix * compress() const
Definition matrix.cpp:1347
Matrix * divide_by_var(int n, int maxd, int &maxdivided) const
Definition matrix.cpp:1062
bool is_equal(const Matrix &m) const
Definition matrix.cpp:312
M2_arrayint elim_vars(int nparts) const
Definition matrix.cpp:1032
Matrix * reshape(const FreeModule *G, const FreeModule *H) const
Definition matrix.cpp:516
const Matrix * content() const
Definition matrix.cpp:2021
Matrix * remove_scalar_multiples() const
Definition matrix.cpp:1437
Matrix * coeffs(M2_arrayint vars, const Matrix *monoms) const
Definition matrix.cpp:1852
Matrix * sub_matrix(M2_arrayint r, M2_arrayint c) const
Definition matrix.cpp:470
Matrix * to_matrix()
void compute_column_degrees()
void set_column_degree(int i, const_monomial deg)
void append(vec v)
void set_entry(int r, int c, ring_elem a)
Mutable builder used to assemble an immutable Matrix one column (or one term) at a time.
unsigned int hash() const
Definition hash.hpp:106
virtual M2SLEvaluator * createSLEvaluator(M2SLProgram *P, M2_arrayint constsPos, M2_arrayint varsPos) const =0
virtual M2SLEvaluator * createCompiledSLEvaluator(M2_string libName, int nInputs, int nOutputs) const =0
Abstract base class for mutable matrices over an arbitrary engine Ring, the in-place counterpart of t...
Definition mat.hpp:79
static PathTracker * make(const Matrix *)
Definition NAG.cpp:1516
Numerical homotopy-continuation path tracker for systems of polynomial equations.
Definition NAG.hpp:654
std::vector< double > RealVector
Definition NAG.hpp:114
int lookup(const RealVector &a) const
Definition NAG.hpp:145
void text_out(buffer &o) const
Definition NAG.hpp:170
int lookup_or_append(const RealVector &a)
Definition NAG.hpp:134
Container of numerical points equipped with an -tolerance and a random weight vector used to bucket a...
Definition NAG.hpp:112
virtual bool promote(const Ring *R, const ring_elem f, ring_elem &result) const =0
virtual FreeModule * make_FreeModule() const
Definition ring.cpp:53
ring_elem zero() const
Definition ring.hpp:359
virtual bool lift(const Ring *R, const ring_elem f, ring_elem &result) const =0
vec copy_vec(const vecterm *v) const
Definition ring-vecs.cpp:91
const Monoid * degree_monoid() const
Definition ring.cpp:13
static RingElement * make_raw(const Ring *R, ring_elem f)
Definition relem.cpp:20
Front-end-visible "ring element" value: an engine ring_elem paired with the Ring* that gives it meani...
Definition relem.hpp:67
xxx xxx xxx
Definition ring.hpp:102
virtual Homotopy * createHomotopy(SLEvaluator *Hxt, SLEvaluator *HxH)=0
virtual bool evaluate(const MutableMatrix *inputs, MutableMatrix *outputs)=0
virtual SLEvaluator * specialize(const MutableMatrix *parameters) const =0
virtual void text_out(buffer &o) const =0
void evaluate(int n, const element_type *values, element_type *out)
Definition NAG.cpp:713
Definition NAG.hpp:485
GATE_POSITION addMProduct(const M2_arrayint)
Definition SLP.cpp:26
GATE_POSITION addDet(const M2_arrayint)
Definition SLP.cpp:35
void text_out(buffer &) const
Definition SLP.cpp:67
GATE_POSITION addDivide(const M2_arrayint)
Definition SLP.cpp:44
void setOutputPositions(const M2_arrayint)
Definition SLP.cpp:53
GATE_POSITION addInput()
Definition SLP-defs.hpp:117
GATE_POSITION addMSum(const M2_arrayint)
Definition SLP.cpp:17
A straight-line program: a directed acyclic graph of arithmetic gates over a fixed list of inputs and...
Definition SLP-defs.hpp:89
static StraightLineProgram * make(const PolyRing *R, ring_elem e)
Definition NAG.cpp:31
void text_out(buffer &o) const
Definition NAG.cpp:46
M2_string to_string()
Definition buffer.cpp:20
DMat<ACoeffRing> — dense-matrix template plus the umbrella that wires in every per-ring specialisatio...
Engine error-reporting primitives: ERROR, INTERNAL_ERROR, error, error_message.
namespace exc — internal C++ exception types and the TRY / CATCH macro pair.
#define Matrix
Definition factory.cpp:14
FreeModule — finite-rank free module R^n, the type-level anchor for every Matrix.
void mpz_reallocate_limbs(mpz_ptr _z)
Definition gmp-util.h:46
Inline helpers that move GMP / MPFR / MPFI limbs from malloc-managed storage into the bdwgc heap.
int p
int zero
const Matrix * IM2_Matrix_monomials(M2_arrayint vars, const Matrix *M)
Definition matrix.cpp:670
gmp_ZZ rawSLPDetGate(M2SLProgram *S, M2_arrayint a)
Definition matrix.cpp:946
M2_string rawPathTrackerToString(PathTracker *p)
Definition matrix.cpp:1030
const Matrix * IM2_Matrix_homogenize(const Matrix *M, int var, M2_arrayint wts)
Definition matrix.cpp:641
unsigned int rawStraightLineProgramHash(StraightLineProgram *slp)
Definition matrix.cpp:989
M2_bool IM2_Matrix_is_implemented_as_dense(const Matrix *M)
Definition matrix.cpp:215
const Matrix * IM2_Matrix_remove_content(const Matrix *M)
Definition matrix.cpp:754
PathTracker * rawPathTracker(const Matrix *HH)
Definition matrix.cpp:1008
const Matrix * IM2_Matrix_koszul(int p, const Matrix *M)
Definition matrix.cpp:506
int IM2_Matrix_n_rows(const Matrix *M)
Definition matrix.cpp:32
const Matrix * rawMatrixReadMsolveString(const Ring *R, M2_string contents)
Definition matrix.cpp:280
const Matrix * IM2_Matrix_tensor(const Matrix *M, const Matrix *N)
Definition matrix.cpp:401
M2_string IM2_Matrix_to_string(const Matrix *M)
Definition matrix.cpp:40
const FreeModule * IM2_Matrix_get_target(const Matrix *M)
Definition matrix.cpp:30
gmp_ZZ rawSLPDivideGate(M2SLProgram *S, M2_arrayint a)
Definition matrix.cpp:955
const Matrix * IM2_Matrix_submatrix1(const Matrix *M, M2_arrayint cols)
Definition matrix.cpp:493
M2_arrayintOrNull IM2_Matrix_sort_columns(const Matrix *M, int deg_order, int mon_order)
Definition matrix.cpp:567
engine_RawMatrixPairOrNull rawTopCoefficients(const Matrix *M)
Definition matrix.cpp:691
const Matrix * rawCoefficients(M2_arrayint vars, const Matrix *monoms, const Matrix *M)
Definition matrix.cpp:648
M2SLEvaluator * rawSLEvaluatorSpecialize(M2SLEvaluator *H, const MutableMatrix *parameters)
Definition matrix.cpp:894
const Matrix * rawMatrixRemoveContent(const Matrix *M)
Definition matrix.cpp:742
unsigned int rawPointArrayHash(M2PointArray *pa)
Definition matrix.cpp:1047
const Matrix * IM2_Matrix_make2(const FreeModule *target, const FreeModule *source, M2_arrayint deg, const engine_RawRingElementArray M, int preference)
Definition matrix.cpp:171
StraightLineProgram * rawSLP(const Matrix *consts, M2_arrayint program)
Definition matrix.cpp:960
const Matrix * IM2_Matrix_submatrix(const Matrix *M, M2_arrayint rows, M2_arrayint cols)
Definition matrix.cpp:479
gmp_ZZ rawSLPProductGate(M2SLProgram *S, M2_arrayint a)
Definition matrix.cpp:942
const Matrix * rawRemoveMonomialFactors(const Matrix *m, M2_bool make_squarefree_only)
Definition matrix.cpp:723
const Matrix * IM2_Matrix_concat(const engine_RawMatrixArray Ms)
Definition matrix.cpp:328
const Matrix * IM2_Matrix_make_sparse1(const FreeModule *target, int ncols, M2_arrayint rows, M2_arrayint cols, const engine_RawRingElementArray entries, int preference)
Definition matrix.cpp:184
gmp_ZZ rawSLPsetOutputPositions(M2SLProgram *S, M2_arrayint a)
Definition matrix.cpp:950
const RingElement * IM2_Matrix_get_entry(const Matrix *M, int r, int c)
Definition matrix.cpp:55
const Matrix * IM2_Matrix_minors(int p, const Matrix *M, int strategy)
Definition matrix.cpp:581
const Matrix * IM2_Matrix_transpose(const Matrix *M)
Definition matrix.cpp:425
const Matrix * IM2_Matrix_reshape(const Matrix *M, const FreeModule *F, const FreeModule *G)
Definition matrix.cpp:437
M2_string rawSLProgramToString(M2SLProgram *slp)
Definition matrix.cpp:930
M2_bool rawSLEvaluatorEvaluate(M2SLEvaluator *sle, const MutableMatrix *inputs, MutableMatrix *outputs)
Definition matrix.cpp:906
int IM2_Matrix_is_equal(const Matrix *M, const Matrix *N)
Definition matrix.cpp:311
const Matrix * IM2_Matrix_exterior(int p, const Matrix *M, int strategy)
Definition matrix.cpp:552
unsigned int rawMatrixHash(const Matrix *M)
Definition matrix.cpp:54
const Matrix * IM2_Matrix_contract(const Matrix *M, const Matrix *N)
Definition matrix.cpp:635
M2PointArray * rawPointArray(double epsilon, int n)
Definition matrix.cpp:1052
const Matrix * rawBasis(const Matrix *M, M2_arrayint lo_degree, M2_arrayint hi_degree, M2_arrayint wt, M2_arrayint vars, M2_bool do_truncation, int limit)
Definition matrix.cpp:655
unsigned int rawHomotopyHash(M2Homotopy *)
Definition matrix.cpp:876
const Matrix * IM2_Matrix_remake2(const FreeModule *target, const FreeModule *source, M2_arrayint deg, const Matrix *M, int preference)
Definition matrix.cpp:225
const Matrix * rawMatrixContent(const Matrix *M)
Definition matrix.cpp:736
M2_string rawStraightLineProgramToString(StraightLineProgram *slp)
Definition matrix.cpp:982
int IM2_Matrix_n_cols(const Matrix *M)
Definition matrix.cpp:33
M2SLEvaluator * rawSLEvaluator(M2SLProgram *SLP, M2_arrayint constsPos, M2_arrayint varsPos, const MutableMatrix *consts)
Definition matrix.cpp:877
M2SLProgram * rawSLProgram(unsigned long nConstantsAndInputs)
Definition matrix.cpp:925
M2_string rawHomotopyToString(M2Homotopy *H)
Definition matrix.cpp:870
engine_RawMatrixAndInt IM2_Matrix_divide_by_var(const Matrix *M, int var, int maxdegree)
Definition matrix.cpp:703
const Matrix * rawMatrixReadMsolveFile(const Ring *R, M2_string filename)
Definition matrix.cpp:294
gmp_ZZ rawSLPSumGate(M2SLProgram *S, M2_arrayint a)
Definition matrix.cpp:938
PathTracker * rawPathTrackerPrecookedSLPs(StraightLineProgram *slp_pred, StraightLineProgram *slp_corr)
PathTracker /////////////////////////////////////////////////////.
Definition matrix.cpp:996
const Matrix * IM2_Matrix_direct_sum(const engine_RawMatrixArray Ms)
Definition matrix.cpp:369
M2_arrayint IM2_Matrix_get_degree(const Matrix *M)
Definition matrix.cpp:35
M2_arrayint IM2_Matrix_elim_vars(int nparts, const Matrix *M)
Definition matrix.cpp:681
unsigned int rawSLEvaluatorHash(M2SLEvaluator *)
Definition matrix.cpp:924
const Matrix * IM2_Matrix_make_sparse2(const FreeModule *target, const FreeModule *source, M2_arrayint deg, M2_arrayint rows, M2_arrayint cols, const engine_RawRingElementArray entries, int preference)
Definition matrix.cpp:199
M2_bool rawHomotopyTrack(M2Homotopy *H, const MutableMatrix *inputs, MutableMatrix *outputs, MutableMatrix *output_extras, gmp_RR init_dt, gmp_RR min_dt, gmp_RR epsilon, int max_corr_steps, gmp_RR infinity_threshold, M2_bool checkPrecision)
Definition matrix.cpp:843
const Matrix * IM2_Matrix_zero(const FreeModule *F, const FreeModule *G, int preference)
Definition matrix.cpp:148
engine_RawRingElementArrayArrayOrNull IM2_Matrix_get_entries(const Matrix *M)
Definition matrix.cpp:85
const Matrix * IM2_Matrix_remake1(const FreeModule *target, const Matrix *M, int preference)
Definition matrix.cpp:242
unsigned int rawPathTrackerHash(PathTracker *p)
Definition matrix.cpp:1037
PointArray::RealVector getRealVector(const MutableMatrix *M, int col)
Definition matrix.cpp:1062
const Matrix * IM2_Matrix_diff(const Matrix *M, const Matrix *N)
Definition matrix.cpp:630
const Matrix * rawKoszulMonomials(int nskew, const Matrix *M, const Matrix *N)
Definition matrix.cpp:518
const Matrix * IM2_Matrix_initial(int nparts, const Matrix *M)
Definition matrix.cpp:676
const RingElement * IM2_Matrix_pfaffian(const Matrix *M)
Definition matrix.cpp:625
const Matrix * rawModuleTensor(const Matrix *M, const Matrix *N)
Definition matrix.cpp:413
const Matrix * rawEvaluateSLP(StraightLineProgram *SLP, const Matrix *vals)
Definition matrix.cpp:971
int rawPointArrayLookupOrAppend(M2PointArray *pa, const MutableMatrix *M, int col)
Definition matrix.cpp:1085
PathTracker * rawPathTrackerProjective(const Matrix *S, const Matrix *T, gmp_RR productST)
Definition matrix.cpp:1018
const Matrix * IM2_Matrix_flip(const FreeModule *F, const FreeModule *G)
Definition matrix.cpp:451
gmp_ZZ to_gmp_ZZ(int a)
Definition matrix.cpp:822
M2_string rawSLEvaluatorToString(M2SLEvaluator *sle)
Definition matrix.cpp:918
M2_arrayint IM2_Matrix_keep_vars(int nparts, const Matrix *M)
Definition matrix.cpp:686
M2Homotopy * rawHomotopy(M2SLEvaluator *Hx, M2SLEvaluator *Hxt, M2SLEvaluator *HxH)
Definition matrix.cpp:831
const Matrix * IM2_Matrix_symm(int p, const Matrix *M)
Definition matrix.cpp:540
M2_bool IM2_Matrix_is_graded(const Matrix *M)
Definition matrix.cpp:327
int rawPointArrayLookup(M2PointArray *pa, const MutableMatrix *M, int col)
Definition matrix.cpp:1080
const Matrix * rawMatrixSplitContent(const Matrix *M, const Matrix **result)
Definition matrix.cpp:747
gmp_ZZ rawSLPInputGate(M2SLProgram *S)
Definition matrix.cpp:937
M2SLEvaluator * rawCompiledSLEvaluator(M2_string libName, int nInputs, int nOutputs, const MutableMatrix *empty)
Definition matrix.cpp:885
const Matrix * rawMatrixCompress(const Matrix *M)
Definition matrix.cpp:721
M2_string rawPointArrayToString(M2PointArray *pa)
Definition matrix.cpp:1040
const Matrix * IM2_Matrix_promote(const FreeModule *newTarget, const Matrix *f)
Definition matrix.cpp:764
const Matrix * IM2_Matrix_pfaffians(int p, const Matrix *M)
Definition matrix.cpp:620
M2_bool IM2_Matrix_is_zero(const Matrix *M)
Definition matrix.cpp:309
const Matrix * rawWedgeProduct(int p, int q, const FreeModule *F)
Definition matrix.cpp:464
const Matrix * rawRemoveScalarMultiples(const Matrix *m)
Definition matrix.cpp:729
const FreeModule * IM2_Matrix_get_source(const Matrix *M)
Definition matrix.cpp:31
const Matrix * IM2_Matrix_identity(const FreeModule *F, int preference)
Definition matrix.cpp:139
unsigned int rawSLProgramHash(M2SLProgram *)
Definition matrix.cpp:936
const Matrix * IM2_Matrix_random(const Ring *R, int r, int c, double fraction_non_zero, int special_type, int preference)
Definition matrix.cpp:265
const Matrix * rawMinors(int p, const Matrix *M, int strategy, int n_minors_to_compute, M2_arrayintOrNull first_row_set, M2_arrayintOrNull first_col_set)
Definition matrix.cpp:595
const Matrix * IM2_Matrix_lift(int *success_return, const FreeModule *newTarget, const Matrix *f)
Definition matrix.cpp:792
const Matrix * IM2_Matrix_make1(const FreeModule *target, int ncols, const engine_RawRingElementArray M, int preference)
Definition matrix.cpp:159
M2_arrayintOrNull rawMatrixIndices(const Matrix *f)
Definition matrix.cpp:667
M2_arrayint to_degree_vector(const Monoid *M, const_monomial d)
Definition monoid.cpp:46
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define getmemarraytype(S, len)
Definition m2-mem.h:142
#define getmemstructtype(S)
Definition m2-mem.h:143
mpfr_srcptr gmp_RR
Definition m2-types.h:148
M2_arrayint M2_arrayintOrNull
Definition m2-types.h:99
struct engine_RawMatrixAndInt_struct * engine_RawMatrixAndInt
Definition m2-types.h:199
char M2_bool
Definition m2-types.h:82
mpz_srcptr gmp_ZZ
Definition m2-types.h:141
engine_RawMatrixPair engine_RawMatrixPairOrNull
Definition m2-types.h:203
engine_RawRingElementArrayArray engine_RawRingElementArrayArrayOrNull
Definition m2-types.h:180
struct engine_RawMatrixPair_struct * engine_RawMatrixPair
Definition m2-types.h:202
MutableMatrix — abstract base of every mutable matrix the engine hands across the boundary.
MatrixConstructor — the mutable builder that produces an immutable Matrix.
Engine-boundary C API for constructing, transforming, and inspecting immutable Matrix objects.
Matrix — the engine's immutable homomorphism F -> G between free modules.
Engine-boundary C API for constructing and inspecting Monoid objects.
MutableMat<Mat> — the templated bridge from DMat / SMat to the abstract MutableMatrix.
Definition aring-CC.cpp:3
RingElement — tagged (Ring*, ring_elem) pair, the engine's universal element type.
tbb::flow::graph G
Ring — the legacy abstract base class for every coefficient and polynomial ring.
ring_elem — the universal value type carried by every Ring* in the engine.
#define T
Definition table.c:13
std::string string_M2_to_std(const M2_string s)
Definition util.hpp:47
std::vector< T > M2_arrayint_to_stdvector(M2_arrayint arr)
Definition util.hpp:96