Documentation ¶
Index ¶
- func Cosd(x float64) float64
- func ElemLength(a, b Vec3) float64
- func Float2d(a, b int) [][]float64
- func Float3d(a, b, c int) [][][]float64
- func Int2d(a, b int) [][]int
- func InvAB(A, B [][]float64, n, m int, AiB [][]float64, ok *bool) (finalErr error)
- func LdlDcmp(a [][]float64, n int, d, b, x []float64, reduce, solve bool) (pd int, err error)
- func LdlDcmpPm(a [][]float64, n int, d, b, x, c []float64, q, r []bool, reduce, solve bool, ...) (err error)
- func LdlMprove(a [][]float64, n int, d, b, x []float64, rmsResID *float64) (ok bool, finalErr error)
- func LdlMprovePm(a [][]float64, n int, d, b, x, c []float64, q, r []bool, rmsResID *float64) (ok bool, finalErr error)
- func LuDcmp(a [][]float64, b []float64, reduce, solve bool) (err error)
- func ProdAB(a, b, c [][]float64, I, J, K int)
- func ProdABj(A, B [][]float64, n, j int, u []float64)
- func PseudoInv(A, Ai [][]float64, n int, m int, beta float64) (finalErr error)
- func Sind(x float64) float64
- func XtAx(A, X, C [][]float64, N, J int)
- func XtAy(x []float64, a [][]float64, y []float64, n int, d []float64) (out float64)
- func XtInvAy(X, A, Y [][]float64, n, m int, Ac [][]float64) (finalErr error)
- type Vec3
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ElemLength ¶
ElemLength calcualtes the distance between two nodes a and b
func LdlDcmp ¶
LdlDcmp solves [A]{x} = {b} simply and efficiently by performing an L D L' - decomposition of [A]. No pivoting is performed. [A] is a symmetric diagonally-dominant matrix of dimension [1..n][1..n]. {b} is a r.h.s. vector of dimension [1..n]. {b} is updated using L D L' and then back-substitution is done to obtain {x} {b} is returned unchanged. ldlDcmp(A,n,d,x,x,1,1,&pd) is valid.
The lower triangle of [A] is replaced by the lower triangle L of the L D L' reduction. The diagonal of D is returned in the vector {d}
usage: double **A, *d, *b, *x; int n, reduce, solve, pd; ldlDcmp ( A, n, d, b, x, reduce, solve, &pd );
H.P. Gavin, Civil Engineering, Duke University, hpgavin@duke.edu 9 Oct 2001 Bathe, Finite Element Procecures in Engineering Analysis, Prentice Hall, 1982
a: the system matrix, and L of the L D L' decomp. b: the right hand side vector x: the solution vector reduce: = true, do a forward reduction of A; = false don't solve: = true, do a back substitution for {x}; = false: don't
n size of a
err: = nil, definite matrix and successful L D L' decomp'n d: diagonal of D in the L D L' - decomp'n
func LdlDcmpPm ¶
func LdlDcmpPm(a [][]float64, n int, d, b, x, c []float64, q, r []bool, reduce, solve bool, pd *int) (err error)
LdlDcmpPm solves partitioned matrix equations
[A_qq]{x_q} + [A_qr]{xR} = {b_q} [ARq]{x_q} + [ARr]{xR} = {bR}+{cR} where {b_q}, {bR}, and {xR} are known and where {x_q} and {cR} are unknown
via L D L' - decomposition of [A_qq]. No pivoting is performed. [A] is a symmetric diagonally-dominant matrix of dimension [1..n][1..n]. {b} is a r.h.s. vector of dimension [1..n]. {b} is updated using L D L' and then back-substitution is done to obtain {x} {b_q} and {bR} are returned unchanged. {cR} is returned as a vector of [1..n] with {c_q}=0. {q} is a vector of the indexes of known values {b_q} {r} is a vector of the indexes of known values {xR}
The lower triangle of [A_qq] is replaced by the lower triangle L of its L D L' reduction. The diagonal of D is returned in the vector {d}
usage: double **A, *d, *b, *x;
int n, reduce, solve, pd; ldlDcmp_pm ( A, n, d, b, x, c, q, r, reduce, solve, &pd );
H.P. Gavin, Civil Engineering, Duke University, hpgavin@duke.edu Bathe, Finite Element Procecures in Engineering Analysis, Prentice Hall, 1982 2014-05-14
double **A, /**< the system matrix, and L of the L D L' decomp.*/ int n, /**< the dimension of the matrix */ double *d, /**< diagonal of D in the L D L' - decomp'n */ double *b, /**< the right hand side vector */ double *x, /**< part of the solution vector */ double *c, /**< the part of the solution vector in the rhs */ int *q, /**< q[j]=1 if b[j] is known; q[j]=0 otherwise */ int *r, /**< r[j]=1 if x[j] is known; r[j]=0 otherwise */ int reduce, /**< 1: do a forward reduction of A; 0: don't */ int solve, /**< 1: do a back substitution for {x}; 0: don't */ int *pd /**< 1: definite matrix and successful L D L' decomp'n*/
func LdlMprove ¶
func LdlMprove(a [][]float64, n int, d, b, x []float64, rmsResID *float64) (ok bool, finalErr error)
LdlMprove improves a solution vector x[1..n] of the linear set of equations [A]{x} = {b}. The matrix A[1..n][1..n], and the vectors b[1..n] and x[1..n] are input, as is the dimension n. The matrix [A] is the L D L' decomposition of the original system matrix, as returned by ldlDcmp(). Also input is the diagonal vector, {d} of [D] of the L D L' decompositon. On output, only {x} is modified to an improved set of values. usage: double **A, *d, *b, *x, rmsResid; int n, ok;
func LdlMprovePm ¶
func LdlMprovePm(a [][]float64, n int, d, b, x, c []float64, q, r []bool, rmsResID *float64) (ok bool, finalErr error)
LdlMprovePm improves a solution vector x[1..n] of the partitioned set of linear equations
[A_qq]{x_q} + [A_qr]{xR} = {b_q} [ARq]{x_q} + [ARr]{xR} = {bR}+{cR} where {b_q}, {bR}, and {xR} are known and where {x_q} and {cR} are unknown
by reducing the residual r_q
A_qq r_q = {b_q} - [A_qq]{x_q+r_q} + [A_qr]{xR}
The matrix A[1..n][1..n], and the vectors b[1..n] and x[1..n] are input, as is the dimension n. The matrix [A] is the L D L' decomposition of the original system matrix, as returned by ldlDcmp_pm(). Also input is the diagonal vector, {d} of [D] of the L D L' decompositon. On output, only {x} is modified to an improved set of values. The calculations in ldlMprove_pm do not involve bR.
usage: double **A, *d, *b, *x, rmsResid;
int n, ok, *q, *r; ldlMprove_pm ( A, n, d, b, x, q, r, &rmsResid, &ok );
double **A, /**< the system matrix, and L of the L D L' decomp.*/ int n, /**< the dimension of the matrix */ double *d, /**< diagonal of D in the L D L' - decomp'n */ double *b, /**< the right hand side vector */ double *x, /**< part of the solution vector */ double *c, /**< the part of the solution vector in the rhs */ int *q, /**< q[j]=1 if b[j] is known; q[j]=0 otherwise */ int *r, /**< r[j]=1 if x[j] is known; r[j]=0 otherwise */ double *rmsResid, /**< root-mean-square of residual error */ int *ok ); /**< 1: >10% reduction in rmsResid; 0: not */
func LuDcmp ¶
LuDcmp solves [A]{x} = {b} simply and efficiently by performing an LU - decomposition of [A]. No pivoting is performed. [a] is a diagonally dominant matrix of dimension [1..n][1..n]. {b} is a r.h.s. vector of dimension [1..n]. {b} is updated using [LU] and then back-substitution is done to obtain {x}. {b} is replaced by {x} and [A] is replaced by the LU - reduction of itself.
usage: double **A, *b; int n, reduce, solve, pd; luDcmp ( A, n, b, reduce, solve, &pd ); 5may98
a, the system matrix, and it's LU- reduction b, the right hand side vector, and the solution vector reduce, true: do a forward reduction; false: don't do the reduction solve, true: do a back substitution for {x}; false: do no bk-sub'n
func PseudoInv ¶
PseudoInv calculates the pseudo-inverse of A.
Ai = inv ( A'*A + beta * trace(A'*A) * I ) * A' beta is a regularization factor, which should be small (1e-10) A is m by n Ai is m by n double **A, /**< an n-by-m matrix */ double **Ai, /**< the pseudo-inverse of A */ int n, int m, /**< matrix dimensions */ double beta, /**< regularization factor */
func XtAx ¶
XtAx carries out matrix-matrix-matrix multiplication for symmetric A C = X' A X where C is J by J
X is N by J A is N by N
7nov02