mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.1
This commit is contained in:
76
help/mat
76
help/mat
@@ -14,7 +14,7 @@ SYNOPSIS
|
||||
TYPES
|
||||
index-range-list range_1 [, range_2, ...] up to 4 ranges
|
||||
range_1, ... integer, or integer_1 : integer_2
|
||||
value, value_1, ... any
|
||||
value, value_1, ... any
|
||||
variable_1 ... lvalue
|
||||
decl declarator = global, static or local
|
||||
id_1, ... identifier
|
||||
@@ -32,7 +32,7 @@ DESCRIPTION
|
||||
If a variable is specified by an expression that is not a symbol with
|
||||
possibly object element specifiers, the expression should be enclosed
|
||||
in parentheses. For example, parentheses are required in
|
||||
mat (A[2]) [3] and mat (*p) [3] but mat P.x [3] is acceptable.
|
||||
mat (A[2]) [3] and mat (*p) [3] but mat P.x [3] is acceptable.
|
||||
|
||||
When an index-range is specified as integer_1 : integer_2, where
|
||||
integer_1 and integer_2 are expressions which evaluate to integers,
|
||||
@@ -64,18 +64,18 @@ DESCRIPTION
|
||||
is p + i as long as A exists and a new value is not assigned to A.
|
||||
|
||||
When a matrix is created, each element is initially assigned the
|
||||
value zero. Other values may be assigned then or later using the
|
||||
value zero. Other values may be assigned then or later using the
|
||||
"= {...}" assignment operation. Thus
|
||||
|
||||
A = {value_0, value_1, ...}
|
||||
|
||||
assigns the values value_0, value_1, ... to the elements A[[0]],
|
||||
A[[1]], ... Any blank "value" is passed over. For example,
|
||||
A[[1]], ... Any blank "value" is passed over. For example,
|
||||
|
||||
A = {1, , 2}
|
||||
|
||||
will assign the value 1 to A[[0]], 2 to A[[2]] and leave all other
|
||||
elements unchanged. Values may also be assigned to elements by
|
||||
elements unchanged. Values may also be assigned to elements by
|
||||
simple assignments, as in A[0,0] = 1, A[0,2] = 2;
|
||||
|
||||
If the index-range is left blank but an initializer list is specified
|
||||
@@ -87,16 +87,16 @@ DESCRIPTION
|
||||
the matrix created is one-dimensional. If the list contains a
|
||||
positive number n of values or blanks, the result is as if the
|
||||
range were specified by [n], i.e. the range of indices is from
|
||||
0 to n - 1. In the above examples, A is of size 2 with A[0] = 1
|
||||
0 to n - 1. In the above examples, A is of size 2 with A[0] = 1
|
||||
and A[1] = 2; B is of size 4 with B[0] = 1, B[1] = B[3] = 0,
|
||||
B[2] = 3. The specification mat[] = { } creates the same as mat[1].
|
||||
|
||||
If the index-range is left blank and no initializer list is specified,
|
||||
as in mat C[] or C = mat[], the matrix assigned to C has zero
|
||||
dimension; this has one element C[]. To assign a value using "= { ...}"
|
||||
dimension; this has one element C[]. To assign a value using "= { ...}"
|
||||
at the same time as creating C, parentheses are required as in
|
||||
(mat[]) = {value} or (mat C[]) = {value}. Later a value may be
|
||||
assigned to C[] by C[] = value or C = {value}.
|
||||
(mat[]) = {value} or (mat C[]) = {value}. Later a value may be
|
||||
assigned to C[] by C[] = value or C = {value}.
|
||||
|
||||
The value assigned at any time to any element of a matrix can be of
|
||||
any type - number, string, list, matrix, object of previously specified
|
||||
@@ -106,7 +106,7 @@ DESCRIPTION
|
||||
If an element of a matrix is a structure for which indices or an
|
||||
object element specifier is required, an element of that structure is
|
||||
referred to by appropriate uses of [ ] or ., and so on if an element
|
||||
of that element is required. For example, one may have an expressions
|
||||
of that element is required. For example, one may have an expressions
|
||||
like
|
||||
|
||||
A[1,2][3].alpha[2];
|
||||
@@ -116,14 +116,14 @@ DESCRIPTION
|
||||
type mat[4] and A is a mat[2,3] matrix. When an element of a matrix
|
||||
is a matrix and the total number of indices does not exceed 4, the
|
||||
indices can be combined into one list, e.g. the A[1,2][3] in the
|
||||
above example can be shortened to A[1,2,3]. (Unlike C, A[1,2] cannot
|
||||
above example can be shortened to A[1,2,3]. (Unlike C, A[1,2] cannot
|
||||
be expressed as A[1][2].)
|
||||
|
||||
The function ismat(V) returns 1 if V is a matrix, 0 otherwise.
|
||||
|
||||
isident(V) returns 1 if V is a square matrix with diagonal elements 1,
|
||||
off-diagonal elements zero, or a zero- or one-dimensional matrix with
|
||||
every element 1; otherwise zero is returned. Thus isident(V) = 1
|
||||
every element 1; otherwise zero is returned. Thus isident(V) = 1
|
||||
indicates that for V * A and A * V where A is any matrix of
|
||||
for which either product is defined and the elements of A are real
|
||||
or complex numbers, that product will equal A.
|
||||
@@ -166,7 +166,7 @@ DESCRIPTION
|
||||
matrices as determined by the later index-range-lists. For
|
||||
example mat[2][3] is a 2-element matrix, each of whose elements has
|
||||
as its value a 3-element matrix. Values may be assigned to the
|
||||
elements of the innermost matrices by nested = {...} operations as in
|
||||
elements of the innermost matrices by nested = {...} operations as in
|
||||
|
||||
mat [2][3] = {{1,2,3},{4,5,6}}
|
||||
|
||||
@@ -187,7 +187,7 @@ DESCRIPTION
|
||||
matmax(A,i) - matmin(A,i) == matmax(B,i) - matmin(B,i),
|
||||
|
||||
One consequence of being the same shape is that the matrices will
|
||||
have the same size. Elements "correspond" if they have the same
|
||||
have the same size. Elements "correspond" if they have the same
|
||||
double-bracket indices; thus A == B implies that A[[i]] == B[[i]]
|
||||
for 0 <= i < size(A) == size(B).
|
||||
|
||||
@@ -195,7 +195,7 @@ DESCRIPTION
|
||||
A - B
|
||||
These are defined A and B have the same shape, the element
|
||||
with double-bracket index j being evaluated by A[[j]] + B[[j]] and
|
||||
A[[j]] - B[[j]], respectively. The index-ranges for the results
|
||||
A[[j]] - B[[j]], respectively. The index-ranges for the results
|
||||
are those for the matrix A.
|
||||
|
||||
A[i,j]
|
||||
@@ -208,7 +208,7 @@ DESCRIPTION
|
||||
|
||||
A * B
|
||||
Multiplication is defined provided certain conditions by the
|
||||
dimensions and shapes of A and B are satisfied. If both have
|
||||
dimensions and shapes of A and B are satisfied. If both have
|
||||
dimension 2 and the column-index-list for A is the same as
|
||||
the row-index-list for B, C = A * B is defined in the usual
|
||||
way so that for i in the row-index-list of A and j in the
|
||||
@@ -243,7 +243,7 @@ DESCRIPTION
|
||||
on the left by the corresponding element of A.
|
||||
|
||||
If A is of dimension 2 and B is of dimension 1, A * B is defined
|
||||
if number of columns in A is the same as the size of A. The
|
||||
if number of columns in A is the same as the size of A. The
|
||||
result has the same index-lists as A; each column of A is
|
||||
multiplied on the right by the corresponding element of B.
|
||||
|
||||
@@ -251,7 +251,7 @@ DESCRIPTION
|
||||
and two-dimensional matrices is particularly simple when all the
|
||||
elements are real or complex numbers and all the index-lists are
|
||||
the same, as occurs, for example, if for some positive integer n,
|
||||
all the matrices start as mat [n] or mat [n,n].
|
||||
all the matrices start as mat [n] or mat [n,n].
|
||||
|
||||
det(A)
|
||||
If A is a square, det(A) is evaluated by an algorithm that returns
|
||||
@@ -265,7 +265,7 @@ DESCRIPTION
|
||||
|
||||
The following functions are defined to return matrices with the same
|
||||
index-ranges as A and the specified operations performed on all
|
||||
elements of A. Here num is an arbitrary complex number (nonzero
|
||||
elements of A. Here num is an arbitrary complex number (nonzero
|
||||
when it is a divisor), int an integer, rnd a rounding-type
|
||||
specifier integer, real a real number.
|
||||
|
||||
@@ -276,8 +276,8 @@ DESCRIPTION
|
||||
conj(A)
|
||||
A << int, A >> int
|
||||
scale(A, int)
|
||||
round(A, int, rnd)
|
||||
bround(A, int, rnd)
|
||||
round(A, int, rnd)
|
||||
bround(A, int, rnd)
|
||||
appr(A, real, rnd)
|
||||
int(A)
|
||||
frac(A)
|
||||
@@ -290,7 +290,7 @@ DESCRIPTION
|
||||
elements.
|
||||
|
||||
If A and B are one-dimension and of size 3, cp(A, B) returns their
|
||||
cross-product.
|
||||
cross-product.
|
||||
|
||||
randperm(A) returns a matrix indexed the same as A in which the elements
|
||||
of A have been randomly permuted.
|
||||
@@ -300,7 +300,7 @@ DESCRIPTION
|
||||
|
||||
If A is an lvalue whose current value is a matrix, matfill(A, v)
|
||||
assigns the value v to every element of A, and if also, A is
|
||||
square, matfill(A, v1, v2) assigns v1 to the off-diagonal elements,
|
||||
square, matfill(A, v1, v2) assigns v1 to the off-diagonal elements,
|
||||
v2 to the diagonal elements. To create and assign to A the unit
|
||||
n * n matrix, one may use matfill(mat A[n,n], 0, 1).
|
||||
|
||||
@@ -310,7 +310,7 @@ DESCRIPTION
|
||||
|
||||
For a two-dimensional matrix A, mattrans(A) returns the transpose
|
||||
of A, i.e. if A is mat[m,n], it returns a mat[n,m] matrix with
|
||||
[i,j] element equal to A[j,i]. For zero- or one-dimensional A,
|
||||
[i,j] element equal to A[j,i]. For zero- or one-dimensional A,
|
||||
mattrace(A) returns a matrix with the same value as A.
|
||||
|
||||
The functions search(A, value, start, end]) and
|
||||
@@ -388,10 +388,36 @@ LIMITS
|
||||
second to invert a 10 * 10 matrix, it will probably take about 1000
|
||||
times as long to invert a 100 * 100 matrix.
|
||||
|
||||
LIBRARY
|
||||
LINK LIBRARY
|
||||
n/a
|
||||
|
||||
SEE ALSO
|
||||
ismat, matdim, matmax, matmin, mattrans, mattrace, matsum, det, inverse,
|
||||
isident, test, config, search, rsearch, reverse, copy, blkcpy, dp, cp,
|
||||
randperm, sort
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: mat,v 29.1 1999/12/14 09:15:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/mat,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:22
|
||||
## File existed as early as: 1991
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
|
Reference in New Issue
Block a user