partial variable assignation or modification
partial variable assignation
x(i,j)=a
x(i)=a
l(i)=a
l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
l(k1)...(kn)(i,j)=a or l(list(k1,...,kn,list(i,j))=a
:x matrix of any kind (constant, sparse, polynomial,...) : :l list : :i,j indices : :k1,...kn indices with integer value : :a new entry value :
MATRIX CASE If x is a matrix the indices i and j, may be: | |
---|---|
:Real scalars or vectors or matrices In this case the values given as indices should be positive and it is only their integer part which taken into account.
: :The : symbol The : symbol stands for “all elements”.
: |
: :LIST OR TLIST CASE
If they are present the ki give the path to a sub-list entry of l data structure. They allow a recursive insertion without intermediate copies. The l(k1)...(kn)(i)=a and l(list(k1,...,kn,i)=a) instructions are interpreted as: lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i) = a lkn-1(kn) = lkn .. = .. l(k1) = lk1 And the l(k1)...(kn)(i,j)=a and l(list(k1,...,kn,list(i,j))=a instructions are interpreted as: lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i,j) = a lkn-1(kn) = lkn .. = .. l(k1)= lk1
i may be :
- a real non negative scalar. l(0)=a adds an entry on the “left” of the list. l(i)=a sets the i entry of the list l to a. If i>size(l), l is previously extended with zero length entries (undefined). l(i)=null() deletes the `i`th list entry.
- a polynomial. If i is a polynomial it is interpreted as horner(i,m) where m=size(l). Even if this feature works for all polynomials, it is recommended to use polynomials in $ for readability.
k1,..kn may be :
- real positive scalar.
- a polynomial, interpreted as horner(ki,m) where m is the corresponding sub-list size.
- a character string associated with a sub-list entry name.
:
For soft coded matrix types such as rational functions and state space linear systems, x(i) syntax must not be used for vector entry insertion due to confusion with list entry insertion. x(1,j) or x(i,1) syntax must be used.
// MATRIX CASE
a=[1 2 3;4 5 6]
a(1,2)=10
a([1 1],2)=[-1;-2]
a(:,1)=[8;5]
a(1,3:-1:1)=[77 44 99]
a(1)=%s
a(6)=%s+1
a(:)=1:6
a([%t %f],1)=33
a(1:2,$-1)=[2;4]
a($:-1:1,1)=[8;7]
a($)=123
//
x='test'
x([4 5])=['4','5']
//
b=[1/%s,(%s+1)/(%s-1)]
b(1,1)=0
b(1,$)=b(1,$)+1
b(2)=[1 2] // the numerator
// LIST OR TLIST CASE
l=`list`_(1,'qwerw',%s)
l(1)='Changed'
l(0)='Added'
l(6)=['one more';'added']
//
//
dts=`list`_(1,`tlist`_(['x';'a';'b'],10,[2 3]));
dts(2).a=33
dts(2)('b')(1,2)=-100