All Functions and Procedures

Name Unit Description
add mtx09
procedure add(var r: mtx; a:mtx; x:double);
r(i,j) = a(i,j) + x
Example
Soft dimensions in arithmetic expressions
add mtx09
procedure add(var r: mtx; a:mtx; b:mtx);
Element / element matrix operation: r = a + b
"a" and "b" must either have the same dimensions or be a row or column vector of the same size as "a" (or "b") or a (1,1) matrix. In the latter cases the row and/or column is duplicated so that the resulting operands have the same sizes; The result "r" dimensions will be that of the largest argument "a" or "b".
Example 1
Example 2
Example 3
Soft dimensions in arithmetic expressions
add mtx09
procedure add(var r: mtx; a:mtx; p:boolean);
Cumulative operator + by row or column depending on p.
If p is true then the result r will have the size of a row of a else a column of a. The value of each element of r is the accumulation by the operator + of the element of the corresponding column ( row ) of a.
Example
add mtx09
procedure add(var x: double; a:mtx);
x += a(i,j) for all i,j
Example
Soft dimensions in arithmetic expressions
add mtx09
procedure add(a, b:mtx);
a = a + b
Example
Soft dimensions in arithmetic expressions
add mtx09
procedure add(var r: mtx; x:double; a:mtx);
r(i,j) = x + a(i,j)
Example
Soft dimensions in arithmetic expressions
add mtx09
procedure add(a: mtx; x: double);
a = a + x
Example
Soft dimensions in arithmetic expressions
apn mtx09
procedure apn(s:string; var f:text); inline;
Open text stream "f" to append to file named "s".
See also: rwr() opn() clo()
Example
append mtx09
procedure append(var f: text); inline;
Pristine freepascal append()
Example
See also the other avatar
append mtx09
function append(var f:text; s:string):boolean;
This function enables to append to a file with a single instruction. It doesn't throw an error if the file named "s" doesn't exist unlike pristine freePascal append() but does a rewrite instead.
Example
See also freePascal append
cat mtx09
procedure cat(var r:mtx; a:mtx);
Matrix right concatenation; i.e. r = [r,a] using Scilab notation.
Example
cat mtx09
procedure cat(var r:mtx; a,b:mtx);
Matrix right concatenation.
Scilab: r = [a,b]
Example
clo mtx09 Close text stream "f". An alias of system.close(). Raises an error if it fails.
See also: opn() rwr() mrd() mwr()
Example
col mtx09
function col(a:mtx; j1, j2: longint): mtx;
Return a slice of a: a(:,j1:j2)
Example
col mtx09
function col(a:mtx): longint; inline;
Return the number of columns of "a".
Example
col mtx09
function col(a:mtx; j1: longint): mtx;
Return a slice of a: a(:,j)
Example
dia mtx09
function dia(a:mtx):mtx;
Return a slice: diagonal elements of "a"
"a" Must be a plain matrix.
Example
dvd mtx09
procedure dvd(var r: mtx; a:mtx; b:mtx);
Element / element matrix operation: r = a / b
"a" and "b" must either have the same dimensions or be a row or column vector of the same size as "a" (or "b") or a (1,1) matrix. In the latter cases the row and/or column is duplicated so that the resulting operands have the same sizes; The result "r" dimensions will be that of the largest argument "a" or "b".
Example 1
Example 2
Example 3
Soft dimensions in arithmetic expressions
dvd mtx09
procedure dvd(var r: mtx; a:mtx; x:double);
r(i,j) = a(i,j) / x
Example
Soft dimensions in arithmetic expressions
dvd mtx09
procedure dvd(a, b:mtx);
a = a / b
Example
Soft dimensions in arithmetic expressions
dvd mtx09
procedure dvd(var r: mtx; x:double; a:mtx);
r(i,j) = x / a(i,j)
Example
Soft dimensions in arithmetic expressions
dvd mtx09
procedure dvd(a: mtx; x: double);
a = a / x
Example
Soft dimensions in arithmetic expressions
dvd mtx09
procedure dvd(var r: mtx; a:mtx; p:boolean);
Cumulative operator / by row or column depending on p.
If p is true then the result r will have the size of a row of a else a column of a. The value of each element of r is the accumulation by the operator / of the element of the corresponding column ( row ) of a.
Example
dvd mtx09
procedure dvd(var x: double; a:mtx);
x /= a(i,j) for all i,j
Example
Soft dimensions in arithmetic expressions
elm mtx09
procedure elm(a:mtx; i, j: longint; x:double);
Assign an element of a: a(i,j) = x
Example
elm mtx09
function elm(a:mtx; i, j: longint):double;
Return a(i,j)
Example
elm mtx09
procedure elm(a:mtx; s:string);
assign elments of "a" with the values given in "s"; "a" can be a slice. The dimensions of "s" and "a" must match in the softdim sense.
Example
elm mtx09
procedure elm(b:mtx; x:double);
Fill "b" with value "x";
"b" must have dimensions. Intended usage: to fill a slice with some special value. e.g. elm( col(a,1), 0.0)
Example
elm mtx09
function elm(a:mtx; b:mtx):boolean;
a(i,j) = b(i,j) for all i,j
b has soft dimensions i.e. rows and/or columns will be duplicated so that it matches the dimensions of a, if it make sense: i.e. b may be (1,1) (1,n) or (m,1) if a is (m,n).
Example 1
Example 2
equ mtx09
procedure equ(var r:mtx; x:double; m, n:longint); inline;
Create matrix "r" with "m" rows and "n" columns, with all elements equal to "x".
Example
equ mtx09
procedure equ(var r:mtx; x: double; a:mtx); inline;
Create matrix "r" of the same size as "a" all elements of "r" equal to "x".
Example
equ mtx09
procedure equ(var r:mtx; a:mtx); inline;
Create a copy "r" of matrix "a"; "r" will be a plain matrix whereas "a" can be a slice.
Example
equ mtx09
procedure equ(var r:mtx; s:string);
Convert the string representation "s" of a matrix into "r"; Within a row elements are separated by spaces or commas and rows are separated by semi-colons.
Alternatively s can be filename[,mtxname] to read from. This is redundant with mrd() but convenient in certain cases e.g. to communicate a table of value smaal (big) in a command line option limited to 255 char. in free Pascal; Example
eye mtx09
procedure eye(var r:mtx; lgn, col: longint);
Equivalent to Scilab r = eye(lgn,col)
Example
eye mtx09
procedure eye(var r:mtx; a:mtx); inline;
Equivalent to Scilab r = eye(a)
Example
fmt mtx09
procedure fmt(d:longint); inline;
Control output format of numbers: pretty or ugly (but more accurate)
d=1
pretty output (default),
d=0
ugly but accurate output.
Example
inv mtx09
function inv(var r:mtx; a:mtx; var d:double):boolean;
Matrix inversion by Gauss/Jordan with maximum pivot. The function returns true if successful.
  • r: inverse of a
  • a: plain mtx or a slice; not modified
  • d: determinant of a
Example
inv mtx09
function inv(a:mtx; var d:double):boolean; inline;
Matrix inversion by Gauss/Jordan with maximum pivot. The function returns true if successful.
  • a: plain mtx, inverted in situ.
  • d: determinant of "a"
Example
lgn mtx09
function lgn(a:mtx; i1,i2: longint): mtx;
Return a slice of "a", adjacent rows from i1 to i2.
Scilab: a(i1:i2,:)
Example
lgn mtx09
procedure lgn(var a:mtx; ri, rx:mtx);
TODO check this and preconditions... Selection and in situ deletion and shift of rows to select regions of interest in a histogram stored in "a". The first column of a must increase monotonously.
"ri": include rows if a(i,1) in any ri bracket "rx": exclude rows if a(i,1) in any rx bracket a should be plain (Warning: no sanity check done !)
replaced by rix() based on roi() and rex() cleaner/faster hopefully safer ! Example
lgn mtx09
function lgn(a:mtx; i1: longint): mtx;
Returns row "i1" of "a" (a slice of "a")
Example
lgn mtx09
function lgn(a:mtx; low, high:double):mtx;
Return a row SLICE of a, defined by a low high bracket on the values of the first colum assumed to be monotonously increasing. a MUST be plain (not a slice).
Example
lgn mtx09
procedure lgn(var a:mtx; ri:mtx);
Select rows of interest depending on values in the 1st column of "a" compared with min max brackets given in each row of "ri". Note: "a" size may decrease by removing all lines not in the roi brackets. Assert that the first col "a" is sorted and monotonously increasing.
Obsolete use roi() instead Example
lgn mtx09
function lgn(a:mtx): longint; inline;
Return the number of rows (french: lignes) of a.
Example
lsp mtx09
procedure lsp(var r:mtx; x0, x1: double; n:longint);
Returns "r", a column vector of "n"+1 elements evenly spaced from "x0" to "x1". Same as Scilab's linspace() function.
Example
lsp mtx09
procedure lsp(a:mtx; x0, x1:double);
Enable to fill a column or row of a table with linearly spaced values. Intended use: lsp(col(table,1),0.0,100.0); to fill the first col. of a table with lin. spaced values of the independant variable.
Example
mat mtx09
function mat(a:mtx):Pmatrix;
map mtx "a" into a GSL matrix pointer (returned by the function).
Note: this is just a hook to use a very small part of the GSL library and mostly to test the concept. The Gnu Scientific Library
mpt mtx09 output fields of a This procedure is intended for debug only.
Example
mpt mtx09 output fields of a along with the comment string s This procedure is intended for debug only.
Example
mrd mtx09
function mrd(var r:mtx):boolean;
Read any matrix from stdin in r; return true if successful.
Example
Example
mrd mtx09
function mrd(var r:mtx; sf:string; sm:string):boolean;
read "r" named "sm" from file "sf": return true if successful.
sm='*' : any matrix
sm='' : first anonymous matrix in file
Example
mrd mtx09
function mrd(var r: mtx; var f: text; mnam:string): boolean;
read in r a matrix named mnam from the opened text stream f.
return true if read was successfull.
Example
mrd mtx09
function mrd(var r: mtx; var f: text): boolean; inline;
Read any matrix from text stream f in r; return true if successful.
Example
mrd mtx09
function mrd(var r:mtx; sf:string):boolean; inline;
read "r" (first named or anonymous matrix) in the file "sf"; return true if successful.
Example
mty mtx09
function mty(a:mtx):boolean; inline;
Return true if "a" is empty or not defined/allocated.
Example
mul mtx09
procedure mul(a, b:mtx);
a = a * b
Example
Soft dimensions in arithmetic expressions
mul mtx09
procedure mul(var r: mtx; a:mtx; p:boolean);
Cumulative operator * by row or column depending on p.
If p is true then the result r will have the size of a row of a else a column of a. The value of each element of r is the accumulation by the operator * of the element of the corresponding column ( row ) of a.
Example
mul mtx09
procedure mul(a: mtx; x: double);
a = a * x
Example
Soft dimensions in arithmetic expressions
mul mtx09
procedure mul(var x: double; a:mtx);
x *= a(i,j) for all i,j
Example
Soft dimensions in arithmetic expressions
mul mtx09
procedure mul(var r: mtx; x:double; a:mtx);
r(i,j) = x * a(i,j)
Example
Soft dimensions in arithmetic expressions
mul mtx09
procedure mul(var r: mtx; a:mtx; x:double);
r(i,j) = a(i,j) * x
Example
Soft dimensions in arithmetic expressions
mul mtx09
procedure mul(var r: mtx; a:mtx; b:mtx);
Element / element matrix operation: r = a * b
"a" and "b" must either have the same dimensions or be a row or column vector of the same size as "a" (or "b") or a (1,1) matrix. In the latter cases the row and/or column is duplicated so that the resulting operands have the same sizes; The result "r" dimensions will be that of the largest argument "a" or "b".
Example 1
Example 2
Example 3
Soft dimensions in arithmetic expressions
mwr mtx09
function mwr(x:double): boolean; inline;
Write a formatted number to stdout (as a 1,1 mtx) with a trailing blank line.
Example
mwr mtx09
function mwr(x:double; var f:text): boolean; inline;
Write a formatted number to an opened text stream (as a 1,1 mtx) with a trailing blank line.
Example
mwr mtx09
function mwr(a:mtx): boolean; inline;
Write mtx "a" to stdout.
Example
mwr mtx09
function mwr(a:mtx; var f:text):boolean;
Write matrix "a" in text stream "f"
The text stream "f" MUST be opened by append or rewrite or apn() or rwr() short name equivalents.
Example
mwr mtx09
function mwr(a:mtx; s:string): boolean;
This function output (append) matrix "a" to the text file named "s".
If "s" is an empty string then stdout is used.
rwr(s) to rewrite from an empty file.
or change append mode to false with rwr(true) : overwrite or rwr(false) ( default behaviour of mwr(a,s) ) to append matrix "a" to file "s"
Example
mwr mtx09
procedure mwr(p:boolean, var f:text); inline;
Print the boolean "p" into the opened text stream "f" as "TRUE" or "FALSE".
Example
mwr mtx09
procedure mwr(p:boolean); inline;
Print the boolean "p" into stdout as 'TRUE' or 'FALSE'
Example
mwr mtx09
procedure mwr(s:string; var f:text); inline;
Print string "s" into the open text stream "f".
Example
mwr mtx09
procedure mwr(s:string); inline;
Print the string "s" into stdout.
Example
mym mtx09
procedure mym(var r:mtx; var x:double; lgn, col:longint);
Memory map: use static memory in mtx objects.
Matrix "r" is created using the memory starting at the location of the variable "x" with the given numbers or rows and columns (in arg. lgn and col). The number of elements of "r" must be equal or smaller than the static array used. The second argument "x" is a variable argument of type double typically the first element of the array: x[1]. This is usefull to alias a static pascal array of double with an mtx object. Some name convention may be used to highlight the connection between the mtx and the static array used.
Example
nam mtx09
procedure nam(var p:mtx; name:string) inline;
assign a name to p
Example
nam mtx09
function nam(p:mtx):string; inline;
return the name of "p"
Example
one mtx09
procedure one(var r:mtx; a:mtx); inline;
Create "r" of the same dim. as "a" filled with 1.0;
Scilab: r=ones(a)
Example
one mtx09
procedure one(var r:mtx; lgn, col: longint); inline;
Create "r(lgn,col)" filled with 1.0;
Scilab: r = ones(lgn,col);
Example
opn mtx09
procedure opn(s:string; var f:text); inline;
Open text stream "f" to read from file named "s". Raises an error if it fails.
NOTE: see also reset()
Example
prd mtx09
function prd(a, b:mtx):double; inline;
Returns the scalar product of vectors "a" and "b"; any combination of row or column vectors with the same number of elements;
Example
prd mtx09
procedure prd(var r: mtx; a, b: mtx);
matrix product; Scilab: r = a * b
The dimensions of "a" and "b" must be compatible with matrix product.
Example
ptr mtx09
function ptr(a:mtx):Pdouble;
This function enables to use plain mtx in an external fortran procedure call.
Example
The fortran code used
reset mtx09
function reset(var f: text; s:string): boolean; inline;
Open text stream "f" to read from file named "s".
Returns false if it fails.
See also opn().
Example
reset mtx09
procedure reset(var f: text); inline;
Pristine freepascal reset: the freepascal standard way to open text streams:
Example
rewrite mtx09
procedure rewrite(var f: text); inline;
Pristine freepascal rewrite.
The freepascal standard way tp open text streams:
Example
rewrite mtx09
function rewrite(var f: text; s:string): boolean; inline;
Open text stream "f" for writing to file "s". Return false if rewrite failed. One may wrap the call with assert() for a simple exception management: assert(rewrite(fo,onam))
Example
rex mtx09
procedure rex(var r:mtx; rx:mtx); inline;
Example
rex mtx09
procedure rex(var m:mtx; lo, hi: double);
  
Example
rix mtx09
  procedure rix(var r:mtx; ri, rx:mtx); inline;
Example
roi mtx09
  procedure roi(var m:mtx; ri:mtx);

Trim a table of data in one or several regions of interest. This function operates on tables (stored in matrix m) whose first column must be a monotonously increasing independant variable. Each row of ri (a 2 column matrix) defines a low and high bracket. Rows of m, whose independant variable (1st col.) is in none of the given brackets are discarded from m. The size of m will therefore eventually decrease.
Regions of interest may overlap, however the first column of ri must increase monotonously. Example
rwr mtx09
procedure rwr(nam:string; var f:text); inline;
This procedure will empty the file "nam" or create it if doesn't exist.
Example
rwr mtx09
procedure rwr(nam:string); inline;
This procedure will empty the file "nam" or create it if doesn't exist.
Example
rwr mtx09
procedure rwr(p:boolean); inline;
Modify append mode of mwr(a:mtx; s:string) procedure. Default is append, rwr(true) will modify this behaviour to write a single mtx in a blank file rather than appending to whatever pre-existing file. This flag will prevail for all mwr(mtx,string) avatar. An alternative is to clear a file with rwr(file_name) preserving the default append mode.
Example
sev mtx09
function sev(var r:mtx; u:mtx; s:mtx):boolean;
  • "r": interpolated table for the vector u and spline table s
  • "u": a vector sorted by increasing values of the independant variable
  • "u" must be plain or a compact slice (1 row but NOT 1 column).
  • "s": a cubic spline interpolation table calculated by spl()
  • return: always true (useless); note todo exception handling harmonisation ?
Example
sev mtx09
function sev(u:double; s:mtx):double;
  • "s" spline interpolation table calculated by spl
  • return: interpolated value for independant variable = "u"
Example
sli mtx09
function sli(a:mtx; l1, l2, c1, c2: longint): mtx;
Return a slice of a; same as Scilab a(l1:l2,c1:c2)
Example
spl mtx09
function spl( var s:mtx; x, y: mtx):boolean;
Wrapper of the fortran source.
  • x independant variable vector
  • y dependant variable vector
  • s the returnes spline table of coefficient
See also sev()
Example
stk mtx09
procedure stk(var r:mtx; a:mtx);
Append "a" below "r"; "a" and "r" must have the same number of columns or be empty.
Scilab: r = [r;a]
Example
stk mtx09
procedure stk(var r:mtx; a,b:mtx);
Stack "a" and "b" and copy in "r"; "a" and "b" must have the same number of columns.
Note: empty mtx are not handled properly, use the other avatar.
Scilab: r=[a;b]
Example
sub mtx09
procedure sub(a, b:mtx);
a = a - b
Example
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(a: mtx; x: double);
a = a - x
Example
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(var r: mtx; x:double; a:mtx);
r(i,j) = x - a(i,j)
Example
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(var r: mtx; a:mtx; b:mtx);
Element / element matrix operation: r = a - b
"a" and "b" must either have the same dimensions or be a row or column vector of the same size as "a" (or "b") or a (1,1) matrix. In the latter cases the row and/or column is duplicated so that the resulting operands have the same sizes; The result "r" dimensions will be that of the largest argument "a" or "b".
Example 1
Example 2
Example 3
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(var r: mtx; a:mtx; x:double);
r(i,j) = a(i,j) - x
Example
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(var x: double; a:mtx);
x -= a(i,j) for all i,j
Example
Soft dimensions in arithmetic expressions
sub mtx09
procedure sub(var r: mtx; a:mtx; p:boolean);
Cumulative operator - by row or column depending on p.
If p is true then the result r will have the size of a row of a else a column of a. The value of each element of r is the accumulation by the operator - of the element of the corresponding column ( row ) of a.
Example
tra mtx09
procedure tra(p: boolean); inline;
Control trace mode; p=true/false : trace on/off When trace mode is on most functions will produce an information in standard output about the function name the dimensions of the const. mtx arguments and output the mtx result of the operation.
Example
tra mtx09
procedure tra; inline;
toggle trace mode on/off. When trace mode is on most functions will produce an information in standard output about the function name and the dimensions of the mtx arguments.
Example
trp mtx09
function trp(a:mtx):mtx;
Return a slice: transposed access to "a"
vec mtx09 map a mtx into a GSL vector pointer.
  • "a" a plain mtx (or compact slice TODO check this);
  • return a GSL's vector pointer.
The Gnu Scientific Library
zer mtx09
procedure zer(var r:mtx; a:mtx); inline;
Create "r" same dimensions as "a" filled with 0;
Scilab: r=zeros(a)
Example
zer mtx09
procedure zer(var r:mtx; lgn, col: longint); inline;
Create "r(lgn,col)" filled with 0;
Scilab: r = zeros(lgn,col);
Example

Generated by PasDoc 0.11.0 on 2010-10-04 16:33:27