mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.5k stars 896 forks source link

MILU0Preconditioner constructor #377

Open wo80 opened 8 years ago

wo80 commented 8 years ago

A parameterless constructor should be added, so instead of having only

MILU0Preconditioner(bool modified = true)

there should be

MILU0Preconditioner() : this(true)
MILU0Preconditioner(bool modified)

Without a parameterless constructor, the following code (used for automated testing) will throw an exception.:

var M = Activator.CreateInstance(typeof(MILU0Preconditioner));

EDIT: Maybe the second constructor should be dropped. One can use object initializers instead:

MILU0Preconditioner() { UseModified = false }
kjbartel commented 8 years ago

Try this: http://stackoverflow.com/questions/11002523/activator-createinstance-with-optional-parameters

-----Original Message----- From: "wo80" notifications@github.com Sent: ‎18/‎02/‎2016 7:16 AM To: "mathnet/mathnet-numerics" mathnet-numerics@noreply.github.com Subject: [mathnet-numerics] MILU0Preconditioner constructor (#377)

A parameterless constructor should be added, so instead of having only MILU0Preconditioner(bool modified = true)there should be MILU0Preconditioner() : this(true) MILU0Preconditioner(bool modified)Without a parameterless constructor, the following code (used for automated testing) will throw an exception.: var preconditioner = Activator.CreateInstance(typeof(MILU0));— Reply to this email directly or view it on GitHub.

wo80 commented 8 years ago

@kjbartel: Thanks for the tip. Works great.

EDIT: the above solution throws for classes that only have one parameterless constructor, so that's not an option.