Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
Loading...
Searching...
No Matches
Standard_functions.h File Reference

Standard numeric constants and matrix utility functions. More...

#include "../../Constants.h"
Include dependency graph for Standard_functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int sgn (int v)
 Returns the sign of an integer.
 
MatrixXcd vectorToMatrix (const vector< vector< complex< double > > > &vec)
 Converts a nested complex vector to an Eigen MatrixXcd.
 
MatrixXd vectorToMatrix (const vector< vector< double > > &vec)
 Converts a nested real vector to an Eigen MatrixXd.
 
vector< vector< complex< double > > > matrixToVector (const MatrixXcd &mat)
 Converts an Eigen MatrixXcd to a nested complex vector.
 
vector< vector< double > > matrixToVector (const MatrixXd &mat)
 Converts an Eigen MatrixXd to a nested real vector.
 
MatrixXcd stack_u_4x_3xN (const MatrixXcd &u1, const MatrixXcd &u2, const MatrixXcd &u3, const MatrixXcd &u4)
 Stacks four input matrices into a single block column.
 
vector< vector< complex< double > > > mat_mul (const vector< vector< complex< double > > > &A, const vector< vector< complex< double > > > &B)
 Complex matrix multiplication using nested vectors.
 
vector< vector< complex< double > > > mul_scalar (const vector< vector< complex< double > > > &A, const complex< double > &scalar)
 Scales every entry of a complex matrix by a scalar.
 
vector< vector< complex< double > > > mat_add (const vector< vector< complex< double > > > &A, const vector< vector< complex< double > > > &B)
 Element-wise addition of two complex matrices.
 
vector< vector< complex< double > > > mat_sub (const vector< vector< complex< double > > > &A, const vector< vector< complex< double > > > &B)
 Element-wise subtraction of two complex matrices.
 
vector< vector< complex< double > > > mat_transpose (const vector< vector< complex< double > > > &A)
 Transposes a complex matrix stored as nested vectors.
 
vector< vector< complex< double > > > get_block (const vector< vector< complex< double > > > &Y, int r_off, int c_off, int r_num, int c_num)
 Extracts a rectangular sub-block from a complex matrix.
 

Variables

const double mu_0
 Vacuum permeability (H/m).
 
const double epsilon_0
 Vacuum permittivity (F/m).
 
const double gamma_num
 Euler–Mascheroni constant.
 

Detailed Description

Standard numeric constants and matrix utility functions.

Provides physical constants, sign helpers, vector/matrix conversions, and basic complex-matrix arithmetic used throughout the solver.

Function Documentation

◆ get_block()

vector< vector< complex< double > > > get_block ( const vector< vector< complex< double > > > &  Y,
int  r_off,
int  c_off,
int  r_num,
int  c_num 
)
extern

Extracts a rectangular sub-block from a complex matrix.

Parameters
YSource matrix.
r_offRow offset (0-based).
c_offColumn offset (0-based).
r_numNumber of rows to extract.
c_numNumber of columns to extract.
Returns
Sub-matrix of size r_num × c_num.

Extracts a rectangular sub-block from a complex matrix.

Parameters
YThe source matrix.
r_offThe starting row index of the block.
c_offThe starting column index of the block.
r_numThe number of rows in the block.
c_numThe number of columns in the block.
Returns
A new matrix containing the specified block.

References j.

Referenced by Element::apply_transformation().

◆ mat_add()

vector< vector< complex< double > > > mat_add ( const vector< vector< complex< double > > > &  A,
const vector< vector< complex< double > > > &  B 
)
extern

Element-wise addition of two complex matrices.

Parameters
AFirst operand.
BSecond operand.
Returns
A + B.

Element-wise addition of two complex matrices.

Parameters
AThe first matrix.
BThe second matrix.
Returns
The resulting matrix C = A + B.

References j.

Referenced by Element::apply_transformation().

◆ mat_mul()

vector< vector< complex< double > > > mat_mul ( const vector< vector< complex< double > > > &  A,
const vector< vector< complex< double > > > &  B 
)
extern

Complex matrix multiplication using nested vectors.

Parameters
ALeft operand.
BRight operand.
Returns
Product A * B.

Complex matrix multiplication using nested vectors.

Parameters
AThe left-hand side matrix.
BThe right-hand side matrix.
Returns
The resulting matrix C = A * B.
Exceptions
std::runtime_errorif matrix dimensions are incompatible for multiplication.

References j.

Referenced by Element::apply_transformation().

◆ mat_sub()

vector< vector< complex< double > > > mat_sub ( const vector< vector< complex< double > > > &  A,
const vector< vector< complex< double > > > &  B 
)
extern

Element-wise subtraction of two complex matrices.

Parameters
AMinuend.
BSubtrahend.
Returns
A - B.

Element-wise subtraction of two complex matrices.

Parameters
AThe matrix from which to subtract.
BThe matrix to subtract.
Returns
The resulting matrix C = A - B.

References j.

◆ mat_transpose()

vector< vector< complex< double > > > mat_transpose ( const vector< vector< complex< double > > > &  A)
extern

Transposes a complex matrix stored as nested vectors.

Parameters
AInput matrix.
Returns
Transpose of A.

Transposes a complex matrix stored as nested vectors.

Parameters
AThe matrix to transpose.
Returns
The transposed matrix.

References j.

Referenced by Element::apply_transformation().

◆ matrixToVector() [1/2]

vector< vector< complex< double > > > matrixToVector ( const MatrixXcd &  mat)
extern

Converts an Eigen MatrixXcd to a nested complex vector.

Parameters
matInput complex matrix.
Returns
2-D vector representation.

Converts an Eigen MatrixXcd to a nested complex vector.

Parameters
matThe input Eigen::MatrixXcd.
Returns
A 2D vector representation of the input matrix.

References j.

Referenced by Converter::plotParticipationFactors().

◆ matrixToVector() [2/2]

vector< vector< double > > matrixToVector ( const MatrixXd &  mat)
extern

Converts an Eigen MatrixXd to a nested real vector.

Parameters
matInput real matrix.
Returns
2-D vector representation.

References j.

◆ mul_scalar()

vector< vector< complex< double > > > mul_scalar ( const vector< vector< complex< double > > > &  A,
const complex< double > &  scalar 
)
extern

Scales every entry of a complex matrix by a scalar.

Parameters
AInput matrix.
scalarComplex scale factor.
Returns
Scaled matrix.

Scales every entry of a complex matrix by a scalar.

Parameters
AThe matrix to be multiplied.
scalarThe complex scalar value.
Returns
The resulting matrix C = A * scalar.

References j.

Referenced by Element::apply_transformation().

◆ sgn()

int sgn ( int  v)
extern

Returns the sign of an integer.

Parameters
vInput value.
Returns
-1, 0, or +1.

Returns the sign of an integer.

Parameters
vThe integer value.
Returns
1 if v > 0, -1 if v < 0, and 0 if v == 0.

Referenced by dq_multiply().

◆ stack_u_4x_3xN()

MatrixXcd stack_u_4x_3xN ( const MatrixXcd &  u1,
const MatrixXcd &  u2,
const MatrixXcd &  u3,
const MatrixXcd &  u4 
)
extern

Stacks four input matrices into a single block column.

Parameters
u1First input block.
u2Second input block.
u3Third input block.
u4Fourth input block.
Returns
Vertically stacked complex matrix.

◆ vectorToMatrix() [1/2]

MatrixXcd vectorToMatrix ( const vector< vector< complex< double > > > &  vec)
extern

Converts a nested complex vector to an Eigen MatrixXcd.

Parameters
vec2-D vector of complex values.
Returns
Equivalent dense complex matrix.

Converts a nested complex vector to an Eigen MatrixXcd.

Parameters
vecThe input 2D vector (matrix).
Returns
An Eigen::MatrixXcd representation of the input vector.
Exceptions
std::runtime_errorif the inner vectors have inconsistent lengths.

References j.

Referenced by StabilityEstimate::compute_transfer_function(), example_MMC(), and example_stability_check().

◆ vectorToMatrix() [2/2]

MatrixXd vectorToMatrix ( const vector< vector< double > > &  vec)
extern

Converts a nested real vector to an Eigen MatrixXd.

Parameters
vec2-D vector of double values.
Returns
Equivalent dense real matrix.

Converts a nested real vector to an Eigen MatrixXd.

Parameters
vecThe input 2D vector (matrix).
Returns
An Eigen::MatrixXcd representation of the input vector.
Exceptions
std::runtime_errorif the inner vectors have inconsistent lengths.

References j.

Variable Documentation

◆ epsilon_0

const double epsilon_0
extern

Vacuum permittivity (F/m).

Vacuum permittivity (F/m).

◆ gamma_num

const double gamma_num
extern

Euler–Mascheroni constant.

Euler–Mascheroni constant.

◆ mu_0

const double mu_0
extern

Vacuum permeability (H/m).

Vacuum permeability (H/m).