Hot answers tagged

18

I like that your braces and indentation is beautifully consistent. But, this is C#, and your Java is showing ;-) - Kudos for the mostly-consistent PascalCase type and member names, but it's the K&R same-line { opening brace that clashes with the typical Allman next-line { opening brace standard most people would expect of C# code: public DMatrix(int n) {...


11

A bug: Transpose does data[i, j] = data[j, i];, but it returns a new matrix, it's not supposed to change the matrix in-place, and that doesn't actually work (going out of range for a non-square matrix and losing data for a square one). Manual loops to copy between arrays: did you know you can use Array.Copy on multi-dimensional arrays? The indexes work as ...


7

New line character differs depending on system. Can't rely on \n. Let me introduce you to your new friend, Environment.NewLine Concatenating strings in a loop is very inefficient. It's recommended to use StringBuilder instead Code reuse. There are a couple of spots where duplicated code can be extracted away. Iterating an array and setting values. This ...


4

Next step: Make it Expression<>-oriented. Making your own math tools is tons of fun and practical! Since you're asking about potential improvements, my suggestion is to move toward Expression<>-oriented coding next. First, you define: public abstract partial class Expression<T> { public T Evaluate() { return this....


Only top voted, non community-wiki answers of a minimum length are eligible