expm

Function expm 

Source
pub fn expm<F>(
    a: &ArrayView2<'_, F>,
    workers: Option<usize>,
) -> LinalgResult<Array2<F>>
where F: Float + NumAssign + Sum + One + ScalarOperand + Send + Sync + 'static,
Expand description

Compute the matrix exponential using Padé approximation.

The matrix exponential is defined as the power series: exp(A) = I + A + A²/2! + A³/3! + …

This function uses the Padé approximation method with scaling and squaring, which is numerically stable and efficient for most matrices.

§Arguments

  • a - Input square matrix
  • workers - Number of worker threads (None = use default)

§Returns

  • Matrix exponential of a

§Examples

use scirs2_core::ndarray::array;
use scirs2_linalg::matrix_functions::expm;

let a = array![[0.0_f64, 1.0], [-1.0, 0.0]]; // Rotation matrix
let exp_a = expm(&a.view(), None).unwrap();

// Expected values are approximately cos(1) and sin(1)
// Exact values would be:
// [[cos(1), sin(1)], [-sin(1), cos(1)]]