Skip to content

Avoidable allocations #1131

Description

@febkor

While C# is pretty fast at allocations, they can have a GC penalty.
Math.NET is generally pretty good at avoiding allocations, but there are a few scenarios that might have slipped through.
These are a few I encountered today:

Avoidable allocations

Here I mainly refer to the Double implementations, though the issues may be more general.

  • DenseVector.InfinityNorm(): avoidable delegate allocations of Math.Max
  • DenseVector.L2Norm(): avoidable delegate allocation
  • Vector.Do*(): scalar operand functions which call out to Map allocate a delegate per call
  • Matrix.DoAdd(), DoSubtract(), DoModulus(), ...: a few scalar operand functions which allocate a delegate per call for use with CommonParallel

Allow reusing allocations

Factorization.DenseLU() doesn't provide a way to input a result matrix, and always does
var factors = (DenseMatrix) matrix.Clone() where matrix is the input matrix and factors is the result of the LU factorization.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions