Prev Next det_by_minor_c

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Compute Determinant using Expansion by Minors

Syntax
d = det_by_minor(an)

Purpose
returns the determinant of the matrix @(@ A @)@ using expansion by minors. The elements of the @(@ n \times n @)@ minor @(@ M @)@ of the matrix @(@ A @)@ are defined, for @(@ i = 0 , \ldots , n-1 @)@ and @(@ j = 0 , \ldots , n-1 @)@, by @[@ M_{i,j} = A_{i, j} @]@

a
The argument a has prototype
    const double* 
a
and is a vector with size @(@ m * m @)@. The elements of the @(@ m \times m @)@ matrix @(@ A @)@ are defined, for @(@ i = 0 , \ldots , m-1 @)@ and @(@ j = 0 , \ldots , m-1 @)@, by @[@ A_{i,j} = a[ i * m + j] @]@

m
The argument m has prototype
    size_t 
m
and is the number of rows (and columns) in the square matrix @(@ A @)@.

Source Code
double det_by_minor(double* a, size_t m)
{   size_t *r, *c, i;
    double value;

    r = (size_t*) malloc( (m+1) * sizeof(size_t) );
    c = (size_t*) malloc( (m+1) * sizeof(size_t) );

    assert(m <= 100);
    for(i = 0; i < m; i++)
    {   r[i] = i+1;
        c[i] = i+1;
    }
    r[m] = 0;
    c[m] = 0;

    value = det_of_minor(a, m, m, r, c);

    free(r);
    free(c);
    return value;
}

Input File: test_more/compare_c/det_by_minor.c