Home Online Manual
Top
Back: Access to elements of a user defined type
Forward: Assignments for user defined types
FastBack: vector
FastForward: cone
Up: User defined types
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.23.4 Commands for user defined types

User defined types are normal data types (which do not belong to a ring, even if they have ring dependent parts), so they can be passed as argument to procedures, and recieved as result from procedures.

In order to apply kernel commands to these types (like string, +), provide a usual procedure (say proc p..) for that task and install it via system("install", user_type , kernel_command ,p, number_of_args );. The user_type and kernel_command have to be given as strings. For kernel_command having a variable number of arguments (internal CMD_M) use 4 independ of the number of really supplied arguments.

List of available kernel commands and the required number_of_args, some accept several variants and appear therefor at several places:

  • inplace binary operands: +,-,*,/,div,%,&,|, [, number_of_args:2
  • unary functions: attrib, bareiss, betti, char, char_series, charstr, cleardenom, close, convhull, defined, deg, degree, denominator, det, dim, dump, ERROR, envelope, execute, facstd, factorize, finduni, gen, getdump, hilb, impart, indepSet, interred, jacob, janet, kbase, killattrib, lead, leadcoef, leadexp, leadmonom, load, ludecomp, maxideal, memory, minbase, minres, monitor, monomial, mult, mstd, nameof, ncols, npars, nrows, numerator, nvars, open, opposite, ord, ordstr, par, pardeg, parstr, preimage, prime, primefactors, prune, qhweight, rank, read, regularity, repart, ringlist, rvar, sba, size, slimgb, sortvec, sqrfree, syz, trace, transpose, twostd, typeof, univariate, var, variables, varstr, vdim, waitfirst, waitall, weight

  • functions with 2 arguments: attrib, betti, bracket, chinrem, coeffs, contract, deg, delete, diff, dim, extgcd, eliminate, exportto, facstd, factorize, farey, fetch, fglm, fglmquot, find, fres, frwalk, gcd, hilb, homog, hres, imap, importfrom, indepSet, insert, interpolation, janet, kbase, kernel, killattrib, koszul, lift, liftstd, load, lres, modulo, mpresmat, mres, newstruct, nc_algebra, nres, oppose, parstr, primefactors, quotient, random, rank, read, sba, simplify, sqrfree, sres, varstr, waitfirst, waitall, wedge

  • functions with 3 arguments: attrib, bareiss, coeffs, eliminate, find, fres, frwalk, hilb, homog, insert, koszul, laguerre, lift, liftstd, newstruct, preimage, random, resultant, sba, vandermonde

  • functions with variable number of arguments arguments (number_of_args:4): breakpoint, coef, dbprint, division, factmodd, intersect, jet, luinverse, lusolve, minor, names, option, qrds, reduce, reservedName, simplex, status, std, subst, system, test, uressolve, write


Example:

 
  newstruct("nt","int a,poly b,string c");
  nt A;
  A;
==> c=
==> b=??
==> a=0
  ring r;
  // a pretty print routine for nt:
  proc pretty_print(nt A)
  {
    "nt with string c:"+A.c+" and poly:"+string(A.b);
  }
  system("install","nt","print",pretty_print,1); // default printing uses print
  A;
==> nt with string c: and poly:0
==> 
  // a custem add for nt:
  proc nt_add(nt A,nt B)
  {
    nt C;
    C.a=A.a+B.a; C.b=A.b+B.b; C.c=A.c+B.c;
    return(C);
  }
  system("install","nt","+",nt_add,2);
  A.b=x;
  nt B; B.c="B"; B.b=y;
  A+B;
==> nt with string c:B and poly:x+y
==>