HTBasic Help
×
Menu
Index

Csolve

Solve a system of linear equations with complex coefficients.
 
Loading        LOADSUB ALL FROM "CSOLVE.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB Csolve FROM "MATHLIB.HTS"
 
Usage                COMPLEX A(*),B(*)
CALL Csolve(A(*),B(*))
 
Description                
Csolve finds the solution to the system of linear equations represented by A and B and returns the solution in B. A must be square, that is, it must have the same number of rows as columns. B must have the same number of rows as A and usually is a one-dimensional array (a vector). If A represents the matrix whose entries are stored in A and b represents the vector whose entries are stored in B, Csolve finds the solution vector, z, for the matrix equation
 
Az = b
 
 
and returns the solution in B, replacing the former contents of B. The contents of the array A are also destroyed by Csolve.
 
The array B may be two-dimensional. In this case, after Csolve executes, each column in B contains the solution vector for the case when the input values in that column were used as b in the above equation.
 
Csolve is equivalent to the BASIC lines
 
MAT Temp=INV(A)
MAT Z=Temp*B
MAT B=Z
 
except that the arrays Temp and Z are not needed; the intermediate results overwrite some of the elements of A. Csolve is faster than the above BASIC fragment, because the matrix inversion is not needed.
 
Errors                
Csolve causes an HTBasic error if its arguments are not both of type COMPLEX, if A is not square or B doesn't have the same number of rows as A, or if A is singular.
 
See Also
Solve