Solvefinds the solution to the system of linear equations represented byAandBand returns the solution inB.Amust be square, that is, it must have the same number of rows as columns.Bmust have the same number of rows asAand usually is a one-dimensional array (a vector). If A represents the matrix whose entries are stored inAand b represents the vector whose entries are stored inB,Solvefinds the solution vector, x, for the matrix equation
Ax = b
and returns the solution inB, replacing the former contents ofB. The contents of the arrayAare also destroyed bySolve.
The arrayBmay be two-dimensional. In this case, aftersolveis called, each column inBcontains the solution vector for the case when the input values in that column were used as b in the above equation.
Solveis equivalent to the BASIC lines
MAT Temp=INV(A)
MAT X=Temp*B
MAT B=X
except that the arraysTempandXare not needed; the intermediate results overwrite some of the elements ofA.Solveis faster than the above BASIC fragment, because the matrix inversion is not needed.
Errors
Solvecauses an HTBasic error if its arguments are both REAL arrays, ifAis not square, ifBdoesn't have the same number of rows asA, or ifAis singular.