[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
newvect
, vector
, vect
:: Creates a new vector object with its length len.
:: Creates a new vector object by elements.
vector
non-negative integer
list
elements of the vector
vect
creates a new vector object by its elements.
vector
is an alias of newvect
.
newvect
creates a new vector object with its length len and its elements
all cleared to value 0.
If the second argument, a list, is given, the vector is initialized by
the list elements.
Elements are used from the first through the last.
If the list is short for initializing the full vector,
0’s are filled in the remaining vector elements.
Note also, in Asir, modification of an element of a vector causes modification of the whole vector itself, while modification of a list element does not cause the modification of the whole list object.
By this, in Asir language, a vector element designator can be a left value of assignment statement, but a list element designator can NOT be a left value of assignment statement.
size()
.
[0] A=newvect(5); [ 0 0 0 0 0 ] [1] A=newvect(5,[1,2,3,4,[5,6]]); [ 1 2 3 4 [5,6] ] [2] A[0]; 1 [3] A[4]; [5,6] [4] size(A); [5] [5] length(A); 5 [6] vect(1,2,3,4,[5,6]); [ 1 2 3 4 [5,6] ] [7] def afo(V) { V[0] = x; } [8] afo(A)$ [9] A; [ x 2 3 4 [5,6] ]
newmat
, matrix
, size
, ltov
, vtol
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ltov
:: Converts a list into a vector.
vector
list
newvect()
.
[3] A=[1,2,3]; [4] ltov(A); [ 1 2 3 ]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
vtol
:: Converts a vector into a list.
list
vector
[vect[0],...,vect[n-1]]
.
newvect()
.
[3] A=newvect(3,[1,2,3]); [ 1 2 3 ] [4] vtol(A); [1,2,3]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
newbytearray
:: Creates a new byte array.
byte array
non-negative integer
list or string
newvect
.
[182] A=newbytearray(3); |00 00 00| [183] A=newbytearray(3,[1,2,3]); |01 02 03| [184] A=newbytearray(3,"abc"); |61 62 63| [185] A[0]; 97 [186] A[1]=123; 123 [187] A; |61 7b 63|
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
newmat
, matrix
:: Creates a new matrix with row rows and col columns.
matrix
non-negative integer
arbitrary
matrix
is an alias of newmat
.
size()
.
M
be a program variable assigned to a matrix.
Then, M[I]
denotes a (row) vector which corresponds with
the I
-th row of the matrix.
Note that the vector shares its element with the original matrix.
Subsequently, if an element of the vector is modified, then the
corresponding matrix element is also modified.
[0] A = newmat(3,3,[[1,1,1],[x,y],[x^2]]); [ 1 1 1 ] [ x y 0 ] [ x^2 0 0 ] [1] det(A); -y*x^2 [2] size(A); [3,3] [3] A[1]; [ x y 0 ] [4] A[1][3]; getarray : Out of range return to toplevel
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mat
, matr
, matc
:: Creates a new matrix by list of row vectors.
:: Creates a new matrix by list of column vectors.
matrix
array or list
mat
is an alias of matr
.
[0] matr([1,2,3],[4,5,6],[7,8]); [ 1 2 3 ] [ 4 5 6 ] [ 7 8 0 ] [1] matc([1,2,3],[4,5,6],[7,8]); [ 1 4 7 ] [ 2 5 8 ] [ 3 6 0 ]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
size
:: A list containing the number of elements of the given vector,
[size of vect]
,
or a list containing row size and column size of the given matrix,
[row size of mat, column size of mat]
.
list
vector
matrix
length()
for the size of list, and
nmono()
for the number of monomials with non-zero coefficients
in a rational expression.
[0] A = newvect(4); [ 0 0 0 0 ] [1] size(A); [4] [2] length(A); 4 [3] B = newmat(2,3,[[1,2,3],[4,5,6]]); [ 1 2 3 ] [ 4 5 6 ] [4] size(B); [2,3]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
det
, nd_det
, invmat
:: Determinant of mat.
:: Inverse matrix of mat.
det
: expression, invmat
: list
matrix
prime
det
and nd_det
compute the determinant of matrix mat.
invmat
computes the inverse matrix of matrix mat.
invmat
returns a list [num,den]
, where num
is a matrix and num/den
represents the inverse matrix.
nd_det
can be used for computing the determinant of a matrix with
polynomial entries over the rationals or finite fields. The algorithm
is an improved vesion of the fraction free Gaussian algorithm
and it computes the determinant faster than det
.
[91] A=newmat(5,5)$ [92] V=[x,y,z,u,v]; [x,y,z,u,v] [93] for(I=0;I<5;I++)for(J=0,B=A[I],W=V[I];J<5;J++)B[J]=W^J; [94] A; [ 1 x x^2 x^3 x^4 ] [ 1 y y^2 y^3 y^4 ] [ 1 z z^2 z^3 z^4 ] [ 1 u u^2 u^3 u^4 ] [ 1 v v^2 v^3 v^4 ] [95] fctr(det(A)); [[1,1],[u-v,1],[-z+v,1],[-z+u,1],[-y+u,1],[y-v,1],[-y+z,1],[-x+u,1], [-x+z,1],[-x+v,1],[-x+y,1]] [96] A = newmat(3,3)$ [97] for(I=0;I<3;I++)for(J=0,B=A[I],W=V[I];J<3;J++)B[J]=W^J; [98] A; [ 1 x x^2 ] [ 1 y y^2 ] [ 1 z z^2 ] [99] invmat(A); [[ -z*y^2+z^2*y z*x^2-z^2*x -y*x^2+y^2*x ] [ y^2-z^2 -x^2+z^2 x^2-y^2 ] [ -y+z x-z -x+y ],(-y+z)*x^2+(y^2-z^2)*x-z*y^2+z^2*y] [100] A*B[0]; [ (-y+z)*x^2+(y^2-z^2)*x-z*y^2+z^2*y 0 0 ] [ 0 (-y+z)*x^2+(y^2-z^2)*x-z*y^2+z^2*y 0 ] [ 0 0 (-y+z)*x^2+(y^2-z^2)*x-z*y^2+z^2*y ] [101] map(red,A*B[0]/B[1]); [ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
qsort
:: Sorts an array array.
array (The same as the input; Only the elements are exchanged.)
array
function for comparison
A<B
if func(A,B)=1
holds, and
the array is sorted in increasing order with respect to the ordering.
[0] qsort(newvect(10,[1,4,6,7,3,2,9,6,0,-1])); [ -1 0 1 2 3 4 6 6 7 9 ] [1] def rev(A,B) { return A>B?-1:(A<B?1:0); } [2] qsort(newvect(10,[1,4,6,7,3,2,9,6,0,-1]),rev); [ 9 7 6 6 4 3 2 1 0 -1 ]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
rowx
, rowm
, rowa
, colx
, colm
, cola
:: Exchanges the i-th and j-th rows.
:: Multiplies the i-th row by c.
:: Appends c times the j-th row to the j-th row.
:: Exchanges the i-th and j-th columns.
:: Multiplies the i-th column by c.
:: Appends c times the j-th column to the j-th column.
matrix
integers
coefficient
[0] A=newmat(3,3,[[1,2,3],[4,5,6],[7,8,9]]); [ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ] [1] rowx(A,1,2)$ [2] A; [ 1 2 3 ] [ 7 8 9 ] [ 4 5 6 ] [3] rowm(A,2,x); [ 1 2 3 ] [ 7 8 9 ] [ 4*x 5*x 6*x ] [4] rowa(A,0,1,z); [ 7*z+1 8*z+2 9*z+3 ] [ 7 8 9 ] [ 4*x 5*x 6*x ]
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |
This document was generated on December 1, 2023 using texi2html 5.0.