pcb 4.1.1
An interactive printed circuit board layout editor.

matrix.c File Reference

#include <math.h>
#include "gts.h"
Include dependency graph for matrix.c:

Go to the source code of this file.

Defines

#define COSALPHA2   0.999695413509
#define SINALPHA2   3.04586490453e-4

Functions

GtsMatrixgts_matrix_new (gdouble a00, gdouble a01, gdouble a02, gdouble a03, gdouble a10, gdouble a11, gdouble a12, gdouble a13, gdouble a20, gdouble a21, gdouble a22, gdouble a23, gdouble a30, gdouble a31, gdouble a32, gdouble a33)
void gts_matrix_assign (GtsMatrix *m, gdouble a00, gdouble a01, gdouble a02, gdouble a03, gdouble a10, gdouble a11, gdouble a12, gdouble a13, gdouble a20, gdouble a21, gdouble a22, gdouble a23, gdouble a30, gdouble a31, gdouble a32, gdouble a33)
GtsMatrixgts_matrix_projection (GtsTriangle *t)
GtsMatrixgts_matrix_transpose (GtsMatrix *m)
static gdouble det2x2 (gdouble a, gdouble b, gdouble c, gdouble d)
static gdouble det3x3 (gdouble a1, gdouble a2, gdouble a3, gdouble b1, gdouble b2, gdouble b3, gdouble c1, gdouble c2, gdouble c3)
gdouble gts_matrix_determinant (GtsMatrix *m)
static GtsMatrixadjoint (GtsMatrix *m)
GtsMatrixgts_matrix_inverse (GtsMatrix *m)
GtsMatrixgts_matrix3_inverse (GtsMatrix *m)
void gts_matrix_print (GtsMatrix *m, FILE *fptr)
void gts_vector_print (GtsVector v, FILE *fptr)
void gts_vector4_print (GtsVector4 v, FILE *fptr)
guint gts_matrix_compatible_row (GtsMatrix *A, GtsVector b, guint n, GtsVector A1, gdouble b1)
guint gts_matrix_quadratic_optimization (GtsMatrix *A, GtsVector b, guint n, GtsMatrix *H, GtsVector c)
void gts_matrix_destroy (GtsMatrix *m)
GtsMatrixgts_matrix_product (GtsMatrix *m1, GtsMatrix *m2)
GtsMatrixgts_matrix_zero (GtsMatrix *m)
GtsMatrixgts_matrix_identity (GtsMatrix *m)
GtsMatrixgts_matrix_scale (GtsMatrix *m, GtsVector s)
GtsMatrixgts_matrix_translate (GtsMatrix *m, GtsVector t)
GtsMatrixgts_matrix_rotate (GtsMatrix *m, GtsVector r, gdouble angle)

Define Documentation

#define COSALPHA2   0.999695413509

Definition at line 424 of file matrix.c.

Referenced by gts_matrix_compatible_row().

#define SINALPHA2   3.04586490453e-4

Definition at line 426 of file matrix.c.

Referenced by gts_matrix_compatible_row().


Function Documentation

static GtsMatrix* adjoint ( GtsMatrix m) [static]

Definition at line 260 of file matrix.c.

References det3x3().

Referenced by gts_matrix_inverse().

Here is the call graph for this function:

static gdouble det2x2 ( gdouble  a,
gdouble  b,
gdouble  c,
gdouble  d 
) [static]

Definition at line 177 of file matrix.c.

References c.

Referenced by det3x3().

static gdouble det3x3 ( gdouble  a1,
gdouble  a2,
gdouble  a3,
gdouble  b1,
gdouble  b2,
gdouble  b3,
gdouble  c1,
gdouble  c2,
gdouble  c3 
) [static]

Definition at line 198 of file matrix.c.

References det2x2().

Referenced by adjoint(), and gts_matrix_determinant().

Here is the call graph for this function:

GtsMatrix* gts_matrix3_inverse ( GtsMatrix m)

gts_matrix3_inverse: : a 3x3 GtsMatrix.

Returns: a pointer to a newly created 3x3 GtsMatrix inverse of or NULL if is not invertible.

Definition at line 340 of file matrix.c.

References det().

Referenced by gts_volume_optimized_vertex().

Here is the call graph for this function:

void gts_matrix_assign ( GtsMatrix m,
gdouble  a00,
gdouble  a01,
gdouble  a02,
gdouble  a03,
gdouble  a10,
gdouble  a11,
gdouble  a12,
gdouble  a13,
gdouble  a20,
gdouble  a21,
gdouble  a22,
gdouble  a23,
gdouble  a30,
gdouble  a31,
gdouble  a32,
gdouble  a33 
)

gts_matrix_assign: : a GtsMatrix. : element [0][0]. : element [0][1]. : element [0][2]. : element [0][3]. : element [1][0]. : element [1][1]. : element [1][2]. : element [1][3]. : element [2][0]. : element [2][1]. : element [2][2]. : element [2][3]. : element [3][0]. : element [3][1]. : element [3][2]. : element [3][3].

Set values of matrix elements.

Definition at line 85 of file matrix.c.

guint gts_matrix_compatible_row ( GtsMatrix A,
GtsVector  b,
guint  n,
GtsVector  A1,
gdouble  b1 
)

gts_matrix_compatible_row: : a GtsMatrix. : a GtsVector.
: the number of previous constraints of .x=. : a GtsMatrix. : a GtsVector.

Given a system of
constraints .x=adds to it the compatible constraints defined by .x=. The compatibility is determined by insuring that the resulting system is well-conditioned (see Lindstrom and Turk (1998, 1999)).

Returns: the number of constraints of the resulting system.

Definition at line 443 of file matrix.c.

References COSALPHA2, gts_vector_cross, gts_vector_scalar, n, s, and SINALPHA2.

Referenced by gts_matrix_quadratic_optimization(), and gts_volume_optimized_vertex().

void gts_matrix_destroy ( GtsMatrix m)

gts_matrix_destroy: : a GtsMatrix.

Free all the memory allocated for .

Definition at line 574 of file matrix.c.

Referenced by gts_volume_optimized_vertex().

gdouble gts_matrix_determinant ( GtsMatrix m)

gts_matrix_determinant: : a GtsMatrix.

Returns: the value of det().

Definition at line 216 of file matrix.c.

References det3x3().

Referenced by gts_matrix_inverse().

Here is the call graph for this function:

GtsMatrix* gts_matrix_identity ( GtsMatrix m)

gts_matrix_identity: : a GtsMatrix or NULL.

Initializes to an identity matrix. Allocates a matrix if is NULL.

Returns: the identity matrix.

Definition at line 633 of file matrix.c.

References gts_matrix_zero(), and m.

Here is the call graph for this function:

GtsMatrix* gts_matrix_inverse ( GtsMatrix m)

gts_matrix_inverse: : a GtsMatrix.

Returns: a pointer to a newly created GtsMatrix inverse of or NULL if is not invertible.

Definition at line 313 of file matrix.c.

References adjoint(), det(), and gts_matrix_determinant().

Here is the call graph for this function:

GtsMatrix* gts_matrix_new ( gdouble  a00,
gdouble  a01,
gdouble  a02,
gdouble  a03,
gdouble  a10,
gdouble  a11,
gdouble  a12,
gdouble  a13,
gdouble  a20,
gdouble  a21,
gdouble  a22,
gdouble  a23,
gdouble  a30,
gdouble  a31,
gdouble  a32,
gdouble  a33 
)

gts_matrix_new: : element [0][0]. : element [0][1]. : element [0][2]. : element [0][3]. : element [1][0]. : element [1][1]. : element [1][2]. : element [1][3]. : element [2][0]. : element [2][1]. : element [2][2]. : element [2][3]. : element [3][0]. : element [3][1]. : element [3][2]. : element [3][3].

Allocates memory and initializes a new GtsMatrix.

Returns: a pointer to the newly created GtsMatrix.

Definition at line 46 of file matrix.c.

References m.

Referenced by gts_volume_optimized_vertex().

void gts_matrix_print ( GtsMatrix m,
FILE *  fptr 
)

gts_matrix_print: : a GtsMatrix. : a file descriptor.

Print to file .

Definition at line 375 of file matrix.c.

Referenced by gts_volume_optimized_vertex().

GtsMatrix* gts_matrix_product ( GtsMatrix m1,
GtsMatrix m2 
)

gts_matrix_product: : a GtsMatrix. : another GtsMatrix.

Returns: a new GtsMatrix, product of and .

Definition at line 586 of file matrix.c.

References m.

GtsMatrix* gts_matrix_projection ( GtsTriangle t)

gts_matrix_projection: : a GtsTriangle.

Creates a new GtsMatrix representing the projection onto a plane of normal given by .

Returns: a pointer to the newly created GtsMatrix.

Definition at line 108 of file matrix.c.

References GTS_POINT, gts_triangle_vertices_edges(), and m.

Here is the call graph for this function:

guint gts_matrix_quadratic_optimization ( GtsMatrix A,
GtsVector  b,
guint  n,
GtsMatrix H,
GtsVector  c 
)

gts_matrix_quadratic_optimization: : a GtsMatrix. : a GtsVector.
: the number of constraints (must be smaller than 3). : a symmetric positive definite Hessian. : a GtsVector.

Solve a quadratic optimization problem: Given a quadratic objective function f which can be written as: f(x) = x^t..x + ^t.x + k, where is the symmetric positive definite Hessian of f and k is a constant, find the minimum of f subject to the set of
prior linear constraints, defined by the first
rows of and (.x = ). The new constraints given by the minimization are added to and only if they are linearly independent as determined by gts_matrix_compatible_row().

Returns: the new number of constraints defined by and .

Definition at line 498 of file matrix.c.

References gts_matrix_compatible_row(), gts_vector_cross, gts_vector_scalar, max, and n.

Referenced by gts_volume_optimized_vertex().

Here is the call graph for this function:

GtsMatrix* gts_matrix_rotate ( GtsMatrix m,
GtsVector  r,
gdouble  angle 
)

gts_matrix_rotate: : a GtsMatrix or NULL. : the rotation axis. : the angle (in radians) to rotate by.

Initializes to a rotation matrix around by . Allocates a new matrix if is NULL.

Returns: the rotation matrix.

Definition at line 692 of file matrix.c.

References c, gts_vector_normalize, m, and s.

GtsMatrix* gts_matrix_scale ( GtsMatrix m,
GtsVector  s 
)

gts_matrix_scale: : a GtsMatrix or NULL. : the scaling vector.

Initializes to a scaling matrix for . Allocates a matrix if is NULL.

Returns: the scaling matrix.

Definition at line 650 of file matrix.c.

References gts_matrix_zero(), and m.

Here is the call graph for this function:

GtsMatrix* gts_matrix_translate ( GtsMatrix m,
GtsVector  t 
)

gts_matrix_translate: : a GtsMatrix or NULL. : the translation vector.

Initializes to a translation matrix for . Allocates a new matrix if is NULL.

Returns: the translation matix.

Definition at line 670 of file matrix.c.

References gts_matrix_zero(), and m.

Here is the call graph for this function:

GtsMatrix* gts_matrix_transpose ( GtsMatrix m)

gts_matrix_transpose: : a GtsMatrix.

Returns: a pointer to a newly created GtsMatrix transposed of .

Definition at line 149 of file matrix.c.

GtsMatrix* gts_matrix_zero ( GtsMatrix m)

gts_matrix_zero: : a GtsMatrix or $NULL.

Initializes to zeros. Allocates a matrix if is NULL.

Returns: the zero'ed matrix.

Definition at line 612 of file matrix.c.

References m.

Referenced by gts_matrix_identity(), gts_matrix_scale(), gts_matrix_translate(), and gts_volume_optimized_vertex().

void gts_vector4_print ( GtsVector4  v,
FILE *  fptr 
)

gts_vector4_print: : a GtsVector4. : a file descriptor.

Print to file .

Definition at line 414 of file matrix.c.

void gts_vector_print ( GtsVector  v,
FILE *  fptr 
)

gts_vector_print: : a GtsVector. : a file descriptor.

Print to file .

Definition at line 398 of file matrix.c.

Referenced by gts_volume_optimized_vertex().