Skip to content

Commit

Permalink
Remove old C++ code for creating SI_ideal/matrix/poly from strings
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 24, 2014
1 parent daf7cdb commit dce71ba
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 159 deletions.
25 changes: 0 additions & 25 deletions src/cxxfuncs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,31 +425,6 @@ Obj FuncSI_Indeterminates(Obj self, Obj rr)
}


/// Installed as SI_ideal method
Obj Func_SI_ideal_from_String(Obj self, Obj rr, Obj st)
{
rr = UnwrapHighlevelWrapper(rr);
if (!ISSINGOBJ(SINGTYPE_RING_IMM, rr)) {
ErrorQuit("Argument rr must be a singular ring",0L,0L);
return Fail;
}
if (!IS_STRING_REP(st)) {
ErrorQuit("Argument st must be a string",0L,0L);
return Fail;
}
ring r = (ring) CXX_SINGOBJ(rr);
if (r != currRing) rChangeCurrRing(r);
const char *p = CSTR_STRING(st);
poly *polylist;
Int len = ParsePolyList(r, p, 100, polylist);
ideal id = idInit(len,1);
Int i;
for (i = 0; i < len; i++)
id->m[i] = polylist[i];
omFree(polylist);
return NEW_SINGOBJ_RING(SINGTYPE_IDEAL, id, r);
}

/// Installed as SI_bigint method
Obj Func_SI_bigint(Obj self, Obj nr)
{
Expand Down
3 changes: 0 additions & 3 deletions src/libsing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", _SI_debug, 1, "obj"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", _SI_ring, 3, "characteristic, names, orderings"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", SI_Indeterminates, 1, "ring"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", _SI_ideal_from_String, 2, "rr, st"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", _SI_MONOMIAL, 3, "ring, coeff, exponents"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", _SI_EVALUATE, 1, "st"),
GVAR_FUNC_TABLE_ENTRY("cxxfuncs.cc", SingularValueOfVar, 1, "name"),
Expand Down Expand Up @@ -75,7 +74,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC_TABLE_ENTRY("calls.cc", SI_SetCurrRing, 1, "r"),
GVAR_FUNC_TABLE_ENTRY("calls.cc", SI_CallProc, 2, "name, args"),

GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_matrix_from_String, 4, "rr, nrrows, nrcols, st"),
GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_bigintmat, 1, "m"),
GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_Matbigintmat, 1, "im"),
GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_intmat, 1, "m"),
Expand All @@ -84,7 +82,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_MatElm, 3, "mat, row, col"),
GVAR_FUNC_TABLE_ENTRY("matrix.cc", _SI_SetMatElm, 4, "mat, row, col, val"),

GVAR_FUNC_TABLE_ENTRY("poly.cc", _SI_poly_from_String, 2, "rr, st"),
GVAR_FUNC_TABLE_ENTRY("poly.cc", _SI_COPY_POLY, 1, "poly"),
GVAR_FUNC_TABLE_ENTRY("poly.cc", _SI_MULT_POLY_NUMBER, 2, "a, b"),

Expand Down
1 change: 0 additions & 1 deletion src/libsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ Obj _SI_TypeObj(Obj o);
Obj Func_SI_ring(Obj self, Obj charact, Obj names, Obj orderings);
Obj FuncSI_RingOfSingobj( Obj self, Obj singobj );
Obj FuncSI_Indeterminates(Obj self, Obj r);
Obj Func_SI_ideal_from_String(Obj self, Obj rr, Obj st);
Obj Func_SI_MONOMIAL(Obj self, Obj rr, Obj coeff, Obj exps);
Obj Func_SI_EVALUATE(Obj self, Obj st);
Obj FuncSingularValueOfVar(Obj self, Obj name);
Expand Down
42 changes: 0 additions & 42 deletions src/matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,6 @@

#include <coeffs/bigintmat.h>


/// Installed as SI_matrix method
Obj Func_SI_matrix_from_String(Obj self, Obj rr, Obj nrrows, Obj nrcols,
Obj st)
{
if (!(IS_INTOBJ(nrrows) && IS_INTOBJ(nrcols) &&
INT_INTOBJ(nrrows) > 0 && INT_INTOBJ(nrcols) > 0)) {
ErrorQuit("nrrows and nrcols must be positive integers",0L,0L);
return Fail;
}
Int c_nrrows = INT_INTOBJ(nrrows);
Int c_nrcols = INT_INTOBJ(nrcols);
rr = UnwrapHighlevelWrapper(rr);
if (!ISSINGOBJ(SINGTYPE_RING_IMM,rr)) {
ErrorQuit("Argument rr must be a singular ring",0L,0L);
return Fail;
}
if (!IS_STRING_REP(st)) {
ErrorQuit("Argument st must be a string",0L,0L);
return Fail;
}
ring r = (ring) CXX_SINGOBJ(rr);
if (r != currRing) rChangeCurrRing(r);
const char *p = CSTR_STRING(st);
poly *polylist;
Int len = ParsePolyList(r, p, (int) (c_nrrows * c_nrrows), polylist);
matrix mat = mpNew(c_nrrows,c_nrcols);
Int i;
Int row = 1;
Int col = 1;
for (i = 0; i < len && row <= c_nrrows; i++) {
MATELEM(mat,row,col) = polylist[i];
col++;
if (col > c_nrcols) {
col = 1;
row++;
}
}
omFree(polylist);
return NEW_SINGOBJ_RING(SINGTYPE_MATRIX, mat, r);
}

/// Installed as SI_bigintmat method
Obj Func_SI_bigintmat(Obj self, Obj m)
{
Expand Down
1 change: 0 additions & 1 deletion src/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "libsing.h"

Obj Func_SI_matrix_from_String(Obj self,Obj rr,Obj nrrows, Obj nrcols, Obj st);
Obj Func_SI_bigintmat(Obj self, Obj m);
Obj Func_SI_Matbigintmat(Obj self, Obj im);
Obj Func_SI_intmat(Obj self, Obj m);
Expand Down
84 changes: 0 additions & 84 deletions src/poly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,90 +71,6 @@ static poly _SI_GET_poly(Obj o, ring &r)
return NULL; // To please the compiler
}

// Our constructors for polynomials:

static poly ParsePoly(ring r, const char *&st)
{
poly p,q;
const char *s;
char *buf;
p = NULL;
bool neg;
if (r != currRing) rChangeCurrRing(r);
while (true) {
while (*st == ' ') st++;
if (*st == '-') {
neg = true;
st++;
while (*st == ' ') st++;
} else neg = false;
s = st;
while ((*s >= '0' && *s <= '9') ||
(*s >= 'a' && *s <= 'z') ||
(*s >= 'A' && *s <= 'Z')) s++;
buf = (char *) omalloc( (s - st)+1 );
strncpy(buf,st,s-st);
buf[s-st] = 0;
s = p_Read(buf,q,r);
s = st + (s - buf);
omFree(buf);
if (s == st) return p;
if (neg) q = p_Neg(q,r);
p = p_Add_q(p,q,r);
st = s;
while (*st == ' ') st++;
if (*st == '+') {
st++;
while (*st == ' ') st++;
}
if (*st == ',' || *st == 0) return p;
}
}

/// Installed as SI_poly method
Obj Func_SI_poly_from_String(Obj self, Obj rr, Obj st)
// st a string or a list of lists or so...
{
rr = UnwrapHighlevelWrapper(rr);
if (!ISSINGOBJ(SINGTYPE_RING_IMM, rr)) {
ErrorQuit("Argument rr must be a singular ring",0L,0L);
return Fail;
}
if (!IS_STRING_REP(st)) {
ErrorQuit("Argument st must be a string",0L,0L);
return Fail;
}
ring r = (ring) CXX_SINGOBJ(rr);
const char *p = CSTR_STRING(st);
poly q = ParsePoly(r,p);
Obj tmp = NEW_SINGOBJ_RING(SINGTYPE_POLY, q, r);
return tmp;
}

int ParsePolyList(ring r, const char *&st, int expected, poly *&res)
{
int alloc = expected;
int len = 0;
res = (poly *) omalloc(sizeof(poly) * alloc);
poly *newres;
poly newpoly;

while (true) {
newpoly = ParsePoly(r,st);
if (len >= alloc) {
alloc *= 2;
newres = (poly *) omalloc(sizeof(poly) * alloc);
memcpy(newres,res,sizeof(poly)*len);
omFree(res);
res = newres;
}
res[len++] = newpoly;
if (*st != ',') return len;
st++;
while (*st == ' ') st++;
}
}

// TODO: _SI_MONOMIAL is only used by examples, do we still need it? For what?
Obj Func_SI_MONOMIAL(Obj self, Obj rr, Obj coeff, Obj exps)
{
Expand Down
3 changes: 0 additions & 3 deletions src/poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

#include "libsing.h"

int ParsePolyList(ring r, const char *&st, int expected, poly *&res);

Obj Func_SI_poly_from_String(Obj self, Obj rr, Obj st);
Obj Func_SI_COPY_POLY(Obj self, Obj po);
Obj Func_SI_MULT_POLY_NUMBER(Obj self, Obj a, Obj b);

Expand Down

0 comments on commit dce71ba

Please sign in to comment.