Numerical Methods

Outline

Introduction

Linear
Equations

Interpolation

Numerical
Solutions

Computer
Measurement

      

Linear algebra libraries

It is convenient to bundle functions into libraries. The functions that were described in the previous sections have been put in a library called matrix.js. The functions are:

  • copy(A) - Returns a copy of matrix A.
  • det(A) - Returns the determinant of square matrix A.
  • dot(A,B) - Returns a matrix that corresponds to the matrix product of matrices A and B.
  • identity(N) - Returns an NxN identity matrix.
  • inverse(A) - Returns the inverse of a square matrix.
  • LU_matrix(A) - Returns the LU matrix of square matrix A. This function overwrites A.
  • function LUP_decomp(A) - LU decomposition with partial pivoting. Returns the LU matrix, the permutation matrix P, and sgn=(-1) times the number of row swaps. This function overwrites A.
  • LU_solve(LU,b) - LU is a square NxN LU-matrix, and b is NxM matrix of M column vectors. Returns x, a NxM matrix of M column vectors. Each column of x is a solution of Ax=b.
  • matrix2tex(A) - Formats a matrix as a tex bmatrix.
  • new_matrix(N,M) - Declares an NxM matrix.
  • permutation(pv) - Returns a permutation matrix. pv is a vector of integers. pv[i] specifies the column of the 1 in row i.
  • pivot(A) - exchanges rows of A to put elements with large absolute values along the diagonal. Returns the permutation matrix P and PA = the matrix product of P times A. This function overwrites A.
  • transpose(A) - Returns the transpose of A.
  • write_matrix(A) - Formats a matrix as text.

The contents of this library are shown in the text area below.

The library can be imported with <script> tags. It is possible to import it as a local file or over the internet by specifying the URL of the file. Examples of both methods of importing the library are given below.

C/C++ libraries

All major computer languages have scientific libraries. Below the Linear Algebra section of the GNU Scientific library manual is embedded.