Allocates Matrix (C.Basic)
Allocate Matrix
This content is checked by fx-9860GII (OS 2.04).
This is on-going project, any changes may be made.
Model
fx-9860G Series
Syntax
Compatible with Casio Basic
1. {<row>,<column>}→Dim A (Allocates matrix)
Compatible + Extended (see Note below)
2. [[<E11>,<E12>, ...][<E21>,<E22>, ...] ... ]→Mat A (Allocates & Initializes Matrix)
Extended (see Note below)
3. [["<string 1>"]["<sring 2>"] ... ]→Mat A (Allocates & Initializes Matrix)
Compatible with Casio Basic
4. ClrMat Mat A (Releases matrix)
Key Press
Dim [F3](CMD) --> [down]/[up] --> [9](9:Dim)
Mat [SHIFT][2]
ClrMat [F3](CMD) --> [down]/[up] --> [9](9:ClrMat)
Function
- Allocates memory for Matrix by setting of row and column number (m, n).
- Allocates and initializes Matrix by setting every elements (<Eij>).
- Allocates and initializes Matrinx by setting strings ("<string n>")
- Releases Matrix memory region.
Description
- User must allocate memory for a matrix before initialize and use it.
- It's recommended that user release the allocated memory for matrix before end of program. Otherwise the allocated memory reamains until the same matrix is allocated or initiaized again.
- <Eij> means an element at row i and column j (see Example 1).
- User can use strings <string n> to allocate and initialize a matrix (see Example 2 & 3).
Example 1
C.Basic allows user to use carriage return and space within [ ]. Allocating and initializing a matrix in the following way is good for easy-to-read sorece code;
[
[0x1234,0x2345,0x3456]
[0x4567,0x5678,0x6789]
[0x789A,0x89AB,0x9ABC]
]→Mat A
User can explicitly write a constant in hexadecimal or binary expression by adding prefix "0x"/"0X" or "0b"/"0B" subsequently.
Example 2
Extended usage of matrix helps strings operation, see following sample;
[
"1:ABC",
"2:DEF",
"3:GHI"
]→Mat S
Locate 1,2,&Mat S[1]
Locate 1,3,&Mat S[2]
Locate 1,4,&S[3]
Locate 1,5,&S[1,3]
Clrmat
This code dislays as follows;
1:ABC
2:DEF
3:GHI
ABC
This way is similar to string handing of C language. Instead of & user can use $.
User can write S[ ] instead of Mat S[ ].
Example 3
[
"ABCD",
"EFGH"
]→Mat B
Locate 1,1,B[1,1]:Locate 4,1,B[1,2]
Locate 7,1,B[1,3]:Locate 10,1,B[1,4]:Locate 13,1,B[1,5]
Locate 1,2,B[2,1]:Locate 4,2,B[2,2]
Locate 7,2,B[2,3]:Locate 10,2,B[2,4]:Locate 13,2,B[2,5]
This code displays as follows;
65 66 67 68 0
69 70 71 72 0
Each element is a charactor code of each alphabet. When allocate the matrix in this way using strings, the matrix is 2 rows x 5 columns, not 2 rows x 4 column. each row corresponds to each string and 0 (zero) is automatically added in the last column.
Copyright (C) 2013 - 2016 Krtyski / egadget.blog.fc2.com All Rights Reserved.
- 関連記事
-
-
Type of Number (C.Basic) 2014/08/01
-
Initialize & Substitute to Matrix (C.Basic) 2014/08/01
-
Allocates Matrix (C.Basic) 2014/08/01
-
Array 2014/08/01
-
'/ Comment-out only for Original Casio Basic 2014/08/01
-