Hello
mat1 :=
[[ a, b ],
[ c, d ]]
mat1[:,1] => [b, d]
mat1[[:,1]] // This case is not recognized.
the output would be [a, c]
mat2 := [[ a, b, c ],[ d ]]
◉ size( mat2 ) [↵] returns 2
◉ dim( mat2 ) [↵] returns 2
for the DIM command, when the argument is not a matrix, please display a warning message
dim( mat2 ) [↵] returns 2
"/!\ the array is not a matrix"
: operator
Modérateur : xcasadmin
-
- Messages : 561
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: : operator
: is not an operator. It's implemented in Xcas for Python compatibility. Since Python does not provide indexes starting at 1, there is no reason to implement [[:,1]]. It's not that I don't want to do it, it's that each time I make a change in the parser, there is a high probability to introduce bugs.
-
- Messages : 561
- Inscription : sam. févr. 04, 2017 11:34 pm
- Localisation : Colombia
- Contact :
Re: : operator
I wanted to have compatibility with matlab =)
A: =
[[8,1,6],
[3,5,7],
[4,9,2]]
1: Index or extract the first row.
A[[1 ,:]] returns
[8,1,6]
2: Index or extract the first and second row.
A[[1..2 ,:]] returns
[[8,1,6],
[3,5,7]]
3: Index or extract the second and third column.
A[[:,2..3]] returns
[[1,6],
[5,7],
[9.2]]
4: Convert to column vector (matrix)
A[:] returns
[[8],
[1],
[6],
[3],
[5],
[7],
[4],
[9],
[2]]
5: Convert to row vector
A[..] returns
[8,1,6,3,5,7,4,9,2]
A: =
[[8,1,6],
[3,5,7],
[4,9,2]]
1: Index or extract the first row.
A[[1 ,:]] returns
[8,1,6]
2: Index or extract the first and second row.
A[[1..2 ,:]] returns
[[8,1,6],
[3,5,7]]
3: Index or extract the second and third column.
A[[:,2..3]] returns
[[1,6],
[5,7],
[9.2]]
4: Convert to column vector (matrix)
A[:] returns
[[8],
[1],
[6],
[3],
[5],
[7],
[4],
[9],
[2]]
5: Convert to row vector
A[..] returns
[8,1,6,3,5,7,4,9,2]
Re: : operator
I don't know how matlab works. I don't think it's really important, matlab users have no reason to run Xcas.