femath

package
v0.0.0-...-9516e97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cosd

func Cosd(x float64) float64

Cosd returns cos(x) in degrees.

func ElemLength

func ElemLength(a, b Vec3) float64

ElemLength calcualtes the distance between two nodes a and b

func Float2d

func Float2d(a, b int) [][]float64

Float2d creates a 2d array of floats with various lengths for each dimension

func Float3d

func Float3d(a, b, c int) [][][]float64

Float3d creates a 3d array of floats with various lengths for each dimension

func Int2d

func Int2d(a, b int) [][]int

Int2d creates a 2d array of ints with various lengths for each dimension

func InvAB

func InvAB(A, B [][]float64, n, m int, AiB [][]float64, ok *bool) (finalErr error)

InvAB calculates the product inv(A) * B

where A is n by n
      B is n by m

6jun07

func LdlDcmp

func LdlDcmp(a [][]float64, n int, d, b, x []float64, reduce, solve bool) (pd int, err error)

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

func LuDcmp(a [][]float64, b []float64, reduce, solve bool) (err error)

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 ProdAB

func ProdAB(a, b, c [][]float64, I, J, K int)

ProdAB performs matrix-matrix multiplication C = A * B 27apr01

func ProdABj

func ProdABj(A, B [][]float64, n, j int, u []float64)

ProdABj performs matrix-matrix multiplication for symmetric A u = A * B(:,j) 27apr01

func PseudoInv

func PseudoInv(A, Ai [][]float64, n int, m int, beta float64) (finalErr error)

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 Sind

func Sind(x float64) float64

Sind returns sin(x) in degrees.

func XtAx

func XtAx(A, X, C [][]float64, N, J int)

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

func XtAy

func XtAy(x []float64, a [][]float64, y []float64, n int, d []float64) (out float64)

XtAy carries out vector-matrix-vector multiplication for symmetric A 7apr9

func XtInvAy

func XtInvAy(X, A, Y [][]float64, n, m int, Ac [][]float64) (finalErr error)

XtInvAy calculates the quadratic form with inverse matrix X' * inv(A) * Y

where A is n by n
      X is n by m
      Y is n by m

15sep01

Types

type Vec3

type Vec3 struct {
	X, Y, Z float64
}

Vec3 represents a 3D coordinate

func (Vec3) Vect3d

func (v Vec3) Vect3d() [3]float64

Vect3d converts a Vec to a 3 element float array for compatibility with bitbucket.org/srosencrantz/vect3d

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL