While generating a test harness for ncpoly_20180402.pdf code (attached)
I stumbled on an inconsistency in ncpolyf.spad.
The files are attached.
Towards the bottom lines 27, 28
vars := transformationVariables(p_12, ’a, ’b);
eqns13 := equationList(p_12, 1);
In order to avoid conflicts elsewhere I changed 'a,'b to 'r,'s .
p_12 was converted as expected but the next line failed.
Inspection of the procedures in ncpolyf.spad revealed that
transformationVariables() executed as expected.
equationList() calls equationMatrices
In equationMatrices the variables expected do not track vars but are
fixed as 'a, 'b.
I can avoid this by modifying Bill Pages test/suggested code (to be
included as a test later) to avoid a conflict, but I think it's bug.
After running Schremp..input this code illustrates the failure again.
vars := transformationVariables(p_12,'a,'b);
equationMatrices(p_12,1)
++Okay
vars := transformationVariables(p_12,'r,'s);
equationMatrices(p_12,1)
But equationList() goes on to use vars()
++ Fail
RayR
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
-- Non-commutative Polynomials in FriCAS
-- Created: Don 2017-02-02 13:40
-- Changed: Sam 2018-03-31 19:16
)abbreviation package NCPOLYF NonCommutativePolynomialFunctions
++ Author: Konrad Schrempf <[email protected]>
++ Date Created: Don 2017-02-02 13:40
++ Date Changed: Sam 2018-03-31 19:16
++ Basic Functions:
++ Related Constructors: NonCommutativePolynomial
++ Also See: XDistributedPolynomial
++ AMS Classifications:
++ Keywords:
++ References:
++ Description:
NonCommutativePolynomialFunctions(VAR, F) : Exports == Implementation where
F : Field
VAR : OrderedSet
NNI ==> NonNegativeInteger
OF ==> OutputForm
G ==> Polynomial(F)
OFM ==> FreeMonoid(VAR)
XDP ==> XDistributedPolynomial(VAR, F)
NCP ==> NonCommutativePolynomial(VAR, F)
TERM ==> Record(k:OFM, c:F)
FACT ==> Record(gen:VAR, exp:NNI)
LMMP ==> LinearMultivariateMatrixPencil(F)
ALTOUT ==> true
FLGDBG ==> true
POS_1 ==> 1$NNI
OFF_2 ==> 2::NNI
Exports == with
leftTransformation : (NCP, Symbol) -> Matrix(G)
++ \spad{leftTransformation(f,a)} returns an admissible
++ row transformation matrix with variables a_{i,j}.
rightTransformation : (NCP, Symbol) -> Matrix(G)
++ \spad{rightTransformation(f,b)} returns an admissible
++ column transformation matrix with variables b_{i,j}.
transformationVariables : (NCP, Symbol, Symbol) -> List(Symbol)
++ \spad{transformationVariables(f,a,b)} returns a list
++ of symbols used in the row and column transformation
++ matrices.
equationMatrices : (NCP, NNI) -> List(Matrix(G))
++ \spad{equationMatrix(f, k)} returns a list of matrices
++ with polynomial entries for each element in the support
++ of f for eliminating the upper right block of size
++ k*(n-1-k).
equationList : (NCP, NNI) -> List(G)
++ \spad{equationLIst(f, k)} uses equationMatrices(f, k)
++ to return a single list.
Implementation == add
leftTransformation (f:NCP, a:Symbol) : Matrix(G) ==
n := size(f)
trf_mtx := new(n, n, 0$G)$Matrix(G)
for k in 1 .. n repeat
qsetelt!(trf_mtx, k, k, 1$G)
if n > 2 then
for i in 1 .. (n-2)::NNI repeat
for j in i+1 .. (n-1)::NNI repeat
qsetelt!(trf_mtx, i, j, ((a[i::OF,j::OF])::Symbol)::G)
trf_mtx
rightTransformation (f:NCP, b:Symbol) : Matrix(G) ==
n := size(f)
trf_mtx := new(n, n, 0$G)$Matrix(G)
for k in 1 .. n repeat
qsetelt!(trf_mtx, k, k, 1$G)
if n > 2 then
for i in 2 .. (n-1)::NNI repeat
for j in i+1 .. n repeat
qsetelt!(trf_mtx, i, j, ((b[i::OF,j::OF])::Symbol)::G)
trf_mtx
transformationVariables (f:NCP, a:Symbol, b:Symbol) : List(Symbol) ==
n := size(f)
lst_sym : List(Symbol) := []
if n > 2 then
for i in (n-1)::NNI .. 2 by -1 repeat
for j in n .. i+1 by -1 repeat
lst_sym := cons((b[i::OF,j::OF])::Symbol, lst_sym)
for i in (n-2)::NNI .. 1 by -1 repeat
for j in (n-1)::NNI .. i+1 by -1 repeat
lst_sym := cons((a[i::OF,j::OF])::Symbol, lst_sym)
lst_sym
-- FIXME: simpler conversation?
equationMatrices (f:NCP, k:NNI) : List(Matrix(G)) ==
m := size(f)
k+2 > m =>
error "NCPOLYF: equationMatrices(f,k) - number of rows too big."
n := m+1
lp := pencil(f)
lst_eqn : List(Matrix(G)) := []
P_wrk := leftTransformation(f, 'a)
Q_wrk := rightTransformation(f, 'b)
A_wrk := new(m, m, 0$G)$Matrix(G)
for l in nelem(lp) .. 1 by -1 repeat
A_tmp := subMatrix(lp, 2, n, 2, n, l)
for i in 1 .. m repeat
for j in 1 .. m repeat
qsetelt!(A_wrk, i, j, qelt(A_tmp, i, j)::G)
E_wrk := P_wrk * A_wrk * Q_wrk
lst_eqn := cons(subMatrix(E_wrk, 1, k, k+2, m), lst_eqn)
lst_eqn
equationList (f:NCP, k:NNI) : List(G) ==
n := size(f)
lst_wrk := equationMatrices(f, k)
lst_eqn : List(G) := []
for k in #lst_wrk .. 1 by -1 repeat
E_wrk := lst_wrk(k)
for i in nrows(E_wrk) .. 1 by -1 repeat
for j in ncols(E_wrk) .. 1 by -1 repeat
lst_eqn := cons(qelt(E_wrk, i, j), lst_eqn)
lst_eqn
)clear all
)read nc_ini03.input
p_01 : NCP := 1 - x*y;
p_02 := p_01 + 2*p_01
rank(p_02)
p_03 := addSTD(p_01, p_01)
size(p_03)
addRows!(p_03, 6, 3, -1);
addColumns!(p_03, 3, 6, 1);
p_03
p_04 := removeRowsColumns(p_03, [3], [3])
addRows!(p_04, 3, 1, 1);
p_05 := removeRowsColumns(p_04, [3], [3])
p_06 := minimize(p_05)
rank(p_06)
p_11 : NCP := x*y*x*y
p_12 := copy(p_11);
p_12(1,5) := -z::XDP;
p_12 := minimize(p_12)
p_13 := 3::NCP
admissibleLinearSystem(p_13)
p_14 : NCP := x*y+z;
representation(p_14)
pencil(p_14)
multiplyRow!(p_14, 3, 7);
p_14
vars := transformationVariables(p_12, 'r, 's);
eqns13 := equationList(p_12, 1);
eqns22 := equationList(p_12, 2);
eqns31 := equationList(p_12, 3);
groe13 := groebner(eqns13::List(DMP(vars, F)));
groe22 := groebner(eqns22::List(DMP(vars, F)));
groe31 := groebner(eqns31::List(DMP(vars, F)));
[groe13, groe22, groe31]
p_21 : NCP := x*(1-y*x)*(3-y*x);
addRows!(p_21, 4, 2, 1);
addColumns!(p_21, 3, 5, -1);
p_21
leftFamily(p_21)
rightFamily(p_21)
vars := transformationVariables(p_21, 'a, 'b)
eqns := equationList(p_21, 3)
groe := groebner(eqns::List(DMP(vars, F)))
trn_21 := blockElimination(p_21,[4,5], [1,2,3],[2,3], [5,6])
p_22 := trn_21(1) * p_21 * trn_21(2)
fct_22 := factorization(p_22);
map(rank, fct_22)
fct_22(1)
fct_22(2)
fct_22(3)