Loading...
Searching...
No Matches
jacobi.hpp File Reference

Function prototypes for the jacobi rotation algorithm. More...

`#include <armadillo>`

Go to the source code of this file.

## Functions

void | jacobi_rotate (arma::mat &A, arma::mat &R, int k, int l)
| Computes a single rotation.
void | jacobi_eigensolver (const arma::mat &A, double eps, arma::vec &eigenvalues, arma::mat &eigenvectors, const int maxiter, int &iterations, bool &converged)
| Solves the eigenvalue problem using the jacobi rotation method.

## Detailed Description

Function prototypes for the jacobi rotation algorithm.

Author
  Cory Alexander Balaton (coryab)
  Janita Ovidie Sandtrøen Willumsen (janitaws)

Bug:
  No known bugs

## Function Documentation

## jacobi_eigensolver()

void jacobi_eigensolver | ( | const arma::mat & | A,
|  | double | eps,
|  | arma::vec & | eigenvalues,
|  | arma::mat & | eigenvectors,
|  | const int | maxiter,
|  | int & | iterations,
|  | bool & | converged
| ) |  |

Solves the eigenvalue problem using the jacobi rotation method.

jacobi_eigensolver Initializes matrices A_m and R before going into the main loop.

For each iteration of the loop, it finds the largest absolute off-diagonal value of A_m, and then calls jacobi_rotate. The loop stops when the largest off-diagonal is less than the tolerance (eps) or if the maximum number of iterations has been reached.

The last thing this function does is to sort the eigenvalues and the corresponding eigenvectors in ascending order.

Parameters

  A | The initial matrix to be solved
  eps | Tolerance
  eigenvalues | A vector that will contain the computed eigenvalues
  eigenvectors | A Matrix that will contain the computed eigenvectors
  maxiter | The max number of iterations allowed
  iterations | To keep track of how many iterations the algorithm used
  converged | Tells the user if the algorithm has converged

Returns
  Void

## jacobi_rotate()

void jacobi_rotate | ( | arma::mat & | A,
|  | arma::mat & | R,
|  | int | k,
|  | int | l
| ) |  |

Computes a single rotation.

jacobi_rotate computes a single rotation for Jacobi's rotation algorithm. It starts by calculating tau, t (tan), c (cos), s (sin) and then updates A and R at rows/columsn k and l.

Parameters

  A | Matrix A (m)
  R | The rotation matrix R (m)
  k | Index of the row with the element of largest absolute value
  l | Index of the column with the element of largest absolute value

Returns
  Void