| IGLib 1.5 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
IG.Num.mat2 Struct Reference

2D matrix, struct implementation. More...

## Public Member Functions
| mat2 (mat2 m)
| Copy constructor. Initializes components of a 2D matrix with components of the specified matrix. More...
| mat2 (double xx, double xy, double yx, double yy)
| Initializes 2D matrix structure with the specified components. More...
| mat2 (double component)
| Initializes 2D with the specified component. More...
| mat2 (vec2 xrow, vec2 yrow)
| Initializes 2D matrix structure with the specified rows. More...
void | Zero ()
| Sets components of the vector to 0.0. More...
void | Set (double comp)
| Sets components of the vector to the specified value. More...
override int | GetHashCode ()
| Returns the hash code (hash function) of the current matrix. More...
override bool | Equals (Object obj)
| Returns a value indicating whether the specified object is equal to the current matrix. More...
mat2 | NormalizedEuclidean ()
| Returns this matrix normalized with Euclidean norm. More...
mat2 | NormalizedForbenius ()
| Returns this matrix normalized with Euclidean norm. More...
mat2 | Normalized1 ()
| Returns this matrix normalized with 1 norm. More...
mat2 | NormalizedInfinity ()
| Returns this matrix normalized with infinity norm. More...
vec2 | Solve (vec2 b)
| Returns solution of system of equations with the current system matrix and the specified right-hand sides. More...
mat2 | Add (mat2 a)
| Returns sum of the current matrix and the specified matrix. More...
mat2 | Subtract (mat2 a)
| Returns difference between the current matrix and the specified matrix. More...
mat2 | MultiplyRight (mat2 b)
| Right-multiplies the current 2D matrix with the specified matrix and returns the product. More...
mat2 | MultiplyLeft (mat2 b)
| Left-multiplies the current 2D matrix with the specified matrix and returns the product. More...
vec2 | Multiply (vec2 b)
| Right-multiplies the current 2D matrix with the specified 2D vector and returns the product. More...
mat2 | Multiply (double b)
| Multiplies the current 2D matrix with the specified scalar and returns the product. More...
override string | ToString ()
| Returns a string representation of this 2D matrix. More...
void | Read ()
| Reads this 2D matrix components from a console. More...
void | Read (string name)
| Reads this 2D matrix components from a console. More...

## Static Public Member Functions
static mat2 | Copy (mat2 m)
| Returns a copy of the specified 2D matrix. More...
static void | Negate (mat2 m, ref mat2 res)
| Negates the specified 2D matrix and stores its copy in the resulting matrix. More...
static int | EigenSystem2d (mat2 a, ref mat2 eigenvec, ref vec2 eigenval)
| Calculates eigenvectors and eigenvalues of a 2x2 matrix a and stores eigenvectors to lines of eigenvec and eigenvalues to eigenval. eigenvec can be the same matrix as a. The number of different real eigenvalues is returned. Ref.: linalg.nb Not tested yet! More...
static mat2 | operator+ (mat2 m)
| Unary plus for 2D matrices, returns the operand. More...
static mat2 | operator- (mat2 a)
| Unary negation for 2D matrices, returns the negative operand. More...
static mat2 | operator+ (mat2 a, mat2 b)
| Matrix addition in 2D. More...
static mat2 | operator- (mat2 a, mat2 b)
| Matrix subtraction in 2D. More...
static mat2 | operator* (mat2 a, mat2 b)
| Matrix multiplication in 2D. More...
static vec2 | operator* (mat2 a, vec2 b)
| Matrix with vector multiplication in 2D. More...
static mat2 | operator* (mat2 a, double b)
| Product of a 2D matrix by a scalar. More...
static mat2 | operator* (double a, mat2 b)
| Product of a 2D matrix by a scalar. More...
static mat2 | operator/ (mat2 a, double b)
| Division of a 2D matrix by a scalar. More...
static bool | operator== (mat2 a, mat2 b)
| Vector comparison. More...
static bool | operator!= (mat2 a, mat2 b)
| Vector comparison, returns true if vectors are different. More...
static void | Example ()
| A short example of how to use mat2 and vec2 structs. More...

## Public Attributes
double | xx
double | xy
double | yx
double | yy

## Properties
double | this[int i, int j]`[get, set]`
| Index operator. More...
vec2 | rowx`[get, set]`
| Gets or sets the x-row of the 2D matrix. More...
vec2 | rowy`[get, set]`
| Gets or sets the y-row of the 2D matrix. More...
vec2 | columnx`[get, set]`
| Gets or sets the x-column of the 2D matrix. More...
vec2 | columny`[get, set]`
| Gets or sets the y-column of the 2D matrix. More...
double | NormForbenius`[get]`
| Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components. More...
double | NormEuclidean`[get]`
| Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components. More...
double | Norm`[get]`
| Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components. More...
double | Norm1`[get]`
| Get the 1 norm of the matrix - maximum over columns of sum of absolute values of components. More...
double | NormInfinity`[get]`
| Get the infinity norm of the matrix - maximum over rows of sum of absolute values of components. More...
double | Determinant`[get]`
| Gets matrix determinant. More...
double | Det`[get]`
| Gets matrix determinant. More...
double | Trace`[get]`
| Gets matrix trace (sum of diagonal elements). More...
mat2 | Transpose`[get]`
| Gets transpose of the current matrix. More...
mat2 | T`[get]`
| Gets transpose of the current matrix. More...
mat2 | Inverse`[get]`
| Gets inverse of the current matrix. More...
mat2 | Inv`[get]`
| Gets inverse of the current matrix. More...

## Detailed Description

2D matrix, struct implementation.

Name of this struct is not in line with conventions. This is intentional in order to prevent mistaking struct implementation for class interpretation.

$A Igor Jul08, Oct10;

## Constructor & Destructor Documentation

IG.Num.mat2.mat2 | ( | mat2 | m | ) |
| inline

Copy constructor. Initializes components of a 2D matrix with components of the specified matrix.

Parameters

  m | Matrix whose components are copied to the initialized matrix.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

IG.Num.mat2.mat2 | ( | double | xx,
|  | double | xy,
|  | double | yx,
|  | double | yy
| ) |  |
| inline

Initializes 2D matrix structure with the specified components.

IG.Num.mat2.mat2 | ( | double | component | ) |
| inline

Initializes 2D with the specified component.

Parameters

  component | Value that is assigned to all matrix components.

IG.Num.mat2.mat2 | ( | vec2 | xrow,
|  | vec2 | yrow
| ) |  |
| inline

Initializes 2D matrix structure with the specified rows.

References IG.Num.vec2.x, and IG.Num.vec2.y.

## Member Function Documentation

void IG.Num.mat2.Zero | ( |  | ) |
| inline

Sets components of the vector to 0.0.

void IG.Num.mat2.Set | ( | double | comp | ) |
| inline

Sets components of the vector to the specified value.

override int IG.Num.mat2.GetHashCode | ( |  | ) |
| inline

Returns the hash code (hash function) of the current matrix.

This method should be consistent with the MatrixBase.GetHashCode method, which is standard for implementations of the IMatrix interface.

Two matrices that have the same equal all elements will produce the same hash codes.

Probability that two different matrixes will produce the same hash code is small but it exists.

Overrides the object.GetHashCode method.

override bool IG.Num.mat2.Equals | ( | Object | obj | ) |
| inline

Returns a value indicating whether the specified object is equal to the current matrix.

True is returned if the object is of type mat2) and has equal elements as the current matrix.

Overrides the object.Equals method.

mat2 IG.Num.mat2.NormalizedEuclidean | ( |  | ) |
| inline

Returns this matrix normalized with Euclidean norm.

mat2 IG.Num.mat2.NormalizedForbenius | ( |  | ) |
| inline

Returns this matrix normalized with Euclidean norm.

mat2 IG.Num.mat2.Normalized1 | ( |  | ) |
| inline

Returns this matrix normalized with 1 norm.

mat2 IG.Num.mat2.NormalizedInfinity | ( |  | ) |
| inline

Returns this matrix normalized with infinity norm.

vec2 IG.Num.mat2.Solve | ( | vec2 | b | ) |
| inline

Returns solution of system of equations with the current system matrix and the specified right-hand sides.

Parameters

  b | Vector of right-hand sides of equations.

Returns

mat2 IG.Num.mat2.Add | ( | mat2 | a | ) |
| inline

Returns sum of the current matrix and the specified matrix.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

Referenced by IG.Num.mat2.operator+().

mat2 IG.Num.mat2.Subtract | ( | mat2 | a | ) |
| inline

Returns difference between the current matrix and the specified matrix.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

Referenced by IG.Num.mat2.operator-().

mat2 IG.Num.mat2.MultiplyRight | ( | mat2 | b | ) |
| inline

Right-multiplies the current 2D matrix with the specified matrix and returns the product.

Parameters

  b | Right-hand side factor of multiplication.

Returns
  this*b

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

Referenced by IG.Num.mat2.MultiplyLeft(), and IG.Num.mat2.operator*().

mat2 IG.Num.mat2.MultiplyLeft | ( | mat2 | b | ) |
| inline

Left-multiplies the current 2D matrix with the specified matrix and returns the product.

Parameters

  b | Left-hand side factor of multiplication.

Returns
  b*this

References IG.Num.mat2.MultiplyRight().

vec2 IG.Num.mat2.Multiply | ( | vec2 | b | ) |
| inline

Right-multiplies the current 2D matrix with the specified 2D vector and returns the product.

Parameters

  b | Right-hand side factor of multiplication.

Returns
  this*b

References IG.Num.vec2.x, and IG.Num.vec2.y.

Referenced by IG.Num.mat2.operator*(), and IG.Num.mat2.operator/().

mat2 IG.Num.mat2.Multiply | ( | double | b | ) |
| inline

Multiplies the current 2D matrix with the specified scalar and returns the product.

Parameters

  b | Factor of multiplication.

Returns
  this*b

static mat2 IG.Num.mat2.Copy | ( | mat2 | m | ) |
| inline static

Returns a copy of the specified 2D matrix.

Parameters

  m | Matrix whose copy is returned.

Referenced by IG.Num.mat2.operator+().

static void IG.Num.mat2.Negate | ( | mat2 | m,
|  | ref mat2 | res
| ) |  |
| inline static

Negates the specified 2D matrix and stores its copy in the resulting matrix.

Parameters

  v | Matrix to be negated.
  res | Matrix where the result is stored.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

Referenced by IG.Num.Matrix2d.Negate().

static int IG.Num.mat2.EigenSystem2d | ( | mat2 | a,
|  | ref mat2 | eigenvec,
|  | ref vec2 | eigenval
| ) |  |
| inline static

Calculates eigenvectors and eigenvalues of a 2x2 matrix a and stores eigenvectors to lines of eigenvec and eigenvalues to eigenval. eigenvec can be the same matrix as a. The number of different real eigenvalues is returned. Ref.: linalg.nb Not tested yet!

Parameters

  a | 2D Matrix whose eigenvalues and eigenvectors are calculated.
  eigenvec | Matrix where eigenvectors are stored as rows.
  eigenval | Vector where eigenvalues are stored.

Returns
  The number of different real eigenvalues.

$A Igor Aug08, Oct10;

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

Referenced by IG.Num.Matrix2d.EigenSystem2d().

static mat2 IG.Num.mat2.operator+ | ( | mat2 | m | ) |
| inline static

Unary plus for 2D matrices, returns the operand.

References IG.Num.mat2.Copy().

static mat2 IG.Num.mat2.operator- | ( | mat2 | a | ) |
| inline static

Unary negation for 2D matrices, returns the negative operand.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

static mat2 IG.Num.mat2.operator+ | ( | mat2 | a,
|  | mat2 | b
| ) |  |
| inline static

Matrix addition in 2D.

References IG.Num.mat2.Add().

static mat2 IG.Num.mat2.operator- | ( | mat2 | a,
|  | mat2 | b
| ) |  |
| inline static

Matrix subtraction in 2D.

References IG.Num.mat2.Subtract().

static mat2 IG.Num.mat2.operator* | ( | mat2 | a,
|  | mat2 | b
| ) |  |
| inline static

Matrix multiplication in 2D.

References IG.Num.mat2.MultiplyRight().

static vec2 IG.Num.mat2.operator* | ( | mat2 | a,
|  | vec2 | b
| ) |  |
| inline static

Matrix with vector multiplication in 2D.

References IG.Num.mat2.Multiply().

static mat2 IG.Num.mat2.operator* | ( | mat2 | a,
|  | double | b
| ) |  |
| inline static

Product of a 2D matrix by a scalar.

References IG.Num.mat2.Multiply().

static mat2 IG.Num.mat2.operator* | ( | double | a,
|  | mat2 | b
| ) |  |
| inline static

Product of a 2D matrix by a scalar.

References IG.Num.mat2.Multiply().

static mat2 IG.Num.mat2.operator/ | ( | mat2 | a,
|  | double | b
| ) |  |
| inline static

Division of a 2D matrix by a scalar.

References IG.Num.mat2.Multiply().

static bool IG.Num.mat2.operator== | ( | mat2 | a,
|  | mat2 | b
| ) |  |
| inline static

Vector comparison.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

static bool IG.Num.mat2.operator!= | ( | mat2 | a,
|  | mat2 | b
| ) |  |
| inline static

Vector comparison, returns true if vectors are different.

References IG.Num.mat2.xx, IG.Num.mat2.xy, IG.Num.mat2.yx, and IG.Num.mat2.yy.

override string IG.Num.mat2.ToString | ( |  | ) |
| inline

Returns a string representation of this 2D matrix.

void IG.Num.mat2.Read | ( |  | ) |
| inline

Reads this 2D matrix components from a console.

Referenced by IG.Num.mat2.Example(), and IG.Num.Matrix2d.Read().

void IG.Num.mat2.Read | ( | string | name | ) |
| inline

Reads this 2D matrix components from a console.

Parameters

  name | Name of the matrix to be read; it is written as orientation to the user and can be null.

References IG.Lib.UtilConsole.Read().

static void IG.Num.mat2.Example | ( |  | ) |
| inline static

A short example of how to use mat2 and vec2 structs.

References IG.Num.A, IG.Num.mat2.Determinant, IG.Num.mat2.Inv, IG.Num.mat2.Inverse, IG.Lib.UtilConsole.Read(), IG.Num.vec2.Read(), IG.Num.mat2.Read(), and IG.Num.mat2.T.

## Member Data Documentation

double IG.Num.mat2.xx

Referenced by IG.Num.mat2.Add(), IG.Num.mat2.EigenSystem2d(), IG.Num.Func2dVectorFormBase.Hessian(), IG.Num.mat2.mat2(), IG.Num.mat2.MultiplyRight(), IG.Num.mat2.Negate(), IG.Num.mat2.operator!=(), IG.Num.mat2.operator-(), IG.Num.mat2.operator==(), and IG.Num.mat2.Subtract().

double IG.Num.mat2.xy

Referenced by IG.Num.mat2.Add(), IG.Num.mat2.EigenSystem2d(), IG.Num.Func2dVectorFormBase.Hessian(), IG.Num.mat2.mat2(), IG.Num.mat2.MultiplyRight(), IG.Num.mat2.Negate(), IG.Num.mat2.operator!=(), IG.Num.mat2.operator-(), IG.Num.mat2.operator==(), and IG.Num.mat2.Subtract().

double IG.Num.mat2.yx

Referenced by IG.Num.mat2.Add(), IG.Num.mat2.EigenSystem2d(), IG.Num.mat2.mat2(), IG.Num.mat2.MultiplyRight(), IG.Num.mat2.Negate(), IG.Num.mat2.operator!=(), IG.Num.mat2.operator-(), IG.Num.mat2.operator==(), and IG.Num.mat2.Subtract().

double IG.Num.mat2.yy

Referenced by IG.Num.mat2.Add(), IG.Num.mat2.EigenSystem2d(), IG.Num.Func2dVectorFormBase.Hessian(), IG.Num.mat2.mat2(), IG.Num.mat2.MultiplyRight(), IG.Num.mat2.Negate(), IG.Num.mat2.operator!=(), IG.Num.mat2.operator-(), IG.Num.mat2.operator==(), and IG.Num.mat2.Subtract().

## Property Documentation

double IG.Num.mat2.this[int i, int j]
| get set

Index operator.

Parameters

  i | Component index.

Returns
  The specified component of a 2D vector.

vec2 IG.Num.mat2.rowx
| get set

Gets or sets the x-row of the 2D matrix.

vec2 IG.Num.mat2.rowy
| get set

Gets or sets the y-row of the 2D matrix.

vec2 IG.Num.mat2.columnx
| get set

Gets or sets the x-column of the 2D matrix.

vec2 IG.Num.mat2.columny
| get set

Gets or sets the y-column of the 2D matrix.

double IG.Num.mat2.NormForbenius
| get

Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components.

double IG.Num.mat2.NormEuclidean
| get

Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components.

double IG.Num.mat2.Norm
| get

Get Forbenius (or euclidean) norm of the matrix - square root of sum of squares of components.

double IG.Num.mat2.Norm1
| get

Get the 1 norm of the matrix - maximum over columns of sum of absolute values of components.

double IG.Num.mat2.NormInfinity
| get

Get the infinity norm of the matrix - maximum over rows of sum of absolute values of components.

double IG.Num.mat2.Determinant
| get

Gets matrix determinant.

Referenced by IG.Num.mat2.Example().

double IG.Num.mat2.Det
| get

Gets matrix determinant.

double IG.Num.mat2.Trace
| get

Gets matrix trace (sum of diagonal elements).

mat2 IG.Num.mat2.Transpose
| get

Gets transpose of the current matrix.

mat2 IG.Num.mat2.T
| get

Gets transpose of the current matrix.

Referenced by IG.Num.mat2.Example().

mat2 IG.Num.mat2.Inverse
| get

Gets inverse of the current matrix.

Referenced by IG.Num.mat2.Example().

mat2 IG.Num.mat2.Inv
| get

Gets inverse of the current matrix.

Referenced by IG.Num.mat2.Example().

The documentation for this struct was generated from the following file:

- igbase/numeric/geometry/Matrix2D.cs