Skip to content

Slow inverting because of determinant computation #70

@antononcube

Description

@antononcube

While working on a article for doing regression based on "Math::Matrix" I found out that the method inverted uses the (lazy) attribute determinant.

Since determinant can be quite slow, I think that the singularity check with determinant should be replaced with a singularity check while pivoting. For example, the main loop can start with:

    for ^$!row-count -> $c {
        my $swap_row_nr = $c;       # make sure that diagonal element != 0, later == 1
        $swap_row_nr++ while $swap_row_nr < $!row-count && @clone[$swap_row_nr][$c] == 0;
        fail "Matrix is not invertible, or singular because defect (determinant = 0)" if $swap_row_nr >= $!row-count;
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions