FYS3150: Project 2
Loading...
Searching...
No Matches
Functions
matrix.hpp File Reference

Function prototypes for creating tridiagonal matrices. More...

#include <armadillo>

Go to the source code of this file.

Functions

arma::mat create_tridiagonal (const arma::vec &a, const arma::vec &d, const arma::vec &e)
 Create a tridiagonal matrix.
 
arma::mat create_tridiagonal (int n, double a, double d, double e)
 Create a tridiagonal matrix.
 
arma::mat create_symmetric_tridiagonal (int n, double a, double d)
 Create a symmetric tridiagonal matrix.
 
double max_offdiag_symmetric (arma::mat &A, int &k, int &l)
 Find the off-diagonal element with the largest absolute value.
 

Detailed Description

Function prototypes for creating tridiagonal matrices.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
Bug:
No known bugs

Function Documentation

◆ create_symmetric_tridiagonal()

arma::mat create_symmetric_tridiagonal ( int  n,
double  a,
double  d 
)

Create a symmetric tridiagonal matrix.

create_symmetric_tridiagonal creates a symmetric tridiagonal matrix by calling create_tridiagonal with the same signature for the off-diagonals.

Parameters
nThe dimensions of the tridiagonal matrix
aThe signature for the off diagonals
dThe signature for the main diagonal
Returns
arma::matrix

◆ create_tridiagonal() [1/2]

arma::mat create_tridiagonal ( const arma::vec &  a,
const arma::vec &  d,
const arma::vec &  e 
)

Create a tridiagonal matrix.

create_tridiagonal creates a tridiagonal matrix by first creating a matrix, filled with zeros, of size NxN where N is the size of the main diagonal matrix. Then it will fill all the values from the vector parameters into the matrix and return it.

Parameters
aVector for the lower diagonal of size N-1
dVector for the main diagonal of size N
eVector for the upper diagonal of size N-1
Returns
arma::matrix

◆ create_tridiagonal() [2/2]

arma::mat create_tridiagonal ( int  n,
double  a,
double  d,
double  e 
)

Create a tridiagonal matrix.

This is an overload that takes doubles for the diagonals instead of vectors. It will create 3 vectors that are filled with the signature provided in the arguments, and then call create_tridiagonal with the vectors as the arguments.

Parameters
nThe dimensions of the tridiagonal matrix
aThe signature for the lower diagonal
dThe signature for the main diagonal
eThe signature for the upper diagonal
Returns
arma::matrix

◆ max_offdiag_symmetric()

double max_offdiag_symmetric ( arma::mat &  A,
int &  k,
int &  l 
)

Find the off-diagonal element with the largest absolute value.

max_offdiag_symmetric find the element with the largest absolute value that isn't in the diagonal. Since this function assumes that the matrix that is given is symmetrical, we only need to loop through the upper diagonals of the matrix.

Parameters
ASymmetric matrix
kVariable to store the row of the return value
lVariable to store the column of the return value
Returns
Double