gap-packages / SingularInterface

A GAP package for accessing Singular from within GAP
https://gap-packages.github.io/SingularInterface/
Other
6 stars 3 forks source link

Improve SI_matrix constructor #29

Open fingolfin opened 10 years ago

fingolfin commented 10 years ago

The following does not work right now:

gap> r := SI_ring(0,["x","y","z"]);; AssignGeneratorVariables(r);
gap> m := SI_matrix(2,2,[1,x,y,z]);
Error, l must only contain singular polynomials
not in any function at line 21 of *stdin*

Instead, I have to write:

gap> m := SI_matrix(2,2,[x^0,x,y,z]);
<singular matrix, 2x2>

It would be convenient if we allowed the use of coefficients there. But perhaps there are pitfalls with that; in that case, we should document those.

The other annoyance is that the above constructor takes a flat list and row/column counts. It would be nice if one could also do this:

gap> m := SI_matrix([[x^0,x],[y,z]]);
fingolfin commented 10 years ago

For the string constructor, we should simply defer to the Singular interpreter. In particular, get rid of ParsePolyList. Instead, implement the "string input" variant of SI_matrix with something like this (pseudo) code:

function(ring, rows, cols, str)
   Singular("matrix m = ", rows, ",", cols, ",", str);
   return SI_ValueOfVar("m")
end;

Of course instead of creating a global interpreter var, we should instead hide this inside a proc and use a local var. But the general idea should be clear.

The same could be used for almost any other kind of Singular object...

But in addition to this "legacy" constructors, we should also have more GAPish constructors, as in my initial report.

fingolfin commented 10 years ago

The second part has been implemented in e4e9a3b0381cd01c8ad32257d5c21835791089db

fingolfin commented 9 years ago

We have these SI_matrix variants:

  1. InstallMethod(SI_matrix, ["IsSI_Object"], _SI_matrix_singular);
  2. InstallMethod(SI_matrix, ["IsSI_Object", "IsPosInt", "IsPosInt"], _SI_matrix_singular);
  3. InstallMethod(SI_matrix, ["IsSI_ring", "IsPosInt", "IsPosInt", "IsStringRep"], ...
  4. InstallMethod(SI_matrix, ["IsPosInt", "IsPosInt", "IsList"], _SI_matrix_from_els);

(1) and (2) come from the Singular interpreter.

(1) can be used for typecasts, e.g. converting a module to a matrix. We should add a variant to it which also takes a ring as parameter, to allow converting intmat and bigintmat to SI_matrix.

I am not completely sure what (2) does. I couldn't get it to work in a quick test just now.

(3) is a thin wrapper around the matrix constructor of the Singular interpreter

(4) is a somewhat more high-level version of 3, which instead of a string (which has to be parsed), takes a list of singular objects (usually SI_polys, but I think we also support SI_number, SI_bigint and GAP ints).

I think a variation of (4) which takes a GAP matrix (list-of-lists) and doesn't need rows and cols parameters, would be helpful esp. for novice users (and rather simple to code in pure GAP code).

Here, too, a version which optionally takes an SI_ring as a first parameter might be helpful.

Perhaps we need others?

fingolfin commented 9 years ago

Oh, and let's not forget about taking qring instead of ring... I think that is why some of the constructors have IsSI_Object as first parameter type.

Perhaps we ought to add a new meta type for "ring or qring".