-
Nerd_STF v3.0.0-beta2 Pre-Release
released this
2024-11-25 10:20:20 -05:00 | 11 commits to v3.0 since this releaseNerd_STF v3.0-beta2
I've added a substantial number of things in this update, mostly matrix related.
List Tuples
In the previous beta, I introduced Combination Indexers for the double and int groups, however a problem was that they only returned
IEnumerables. So while some interesting things were supported, some things were not.Float4 wxyz = (1, 2, 3, 4); IEnumerable<double> vals1 = wxyz["xy"]; // Yields [2, 3] Float2 vals2 = wxyz["xy"]; // Not allowed!And that kind of sucked. So I created the
ListTuple<T>type. It's job is to act like a regular tuple, but be able to impliclty convert to either anIEnumerableor a regularValueTuple<T>, thus allowing conversions to the double and int groups indirectly. Now, all combination indexers return aListTupleinstead of anIEnumerable.Under the hood, the
ListTupleactually uses an array, but you get the idea.Float4 wxyz = (1, 2, 3, 4); ListTuple<double> vals1 = wxyz["xy"]; // Yields (2, 3) Float2 vals2 = vals1; // Yields (2, 3) IEnumerable<double> vals3 = vals1; // Yields [2, 3]Problem is, now the names have the potential to make much less sense.
Float4 wxyz = (1, 2, 3, 4); Float2 xy = wxyz["xy"]; // x <- x, y <- y Float2 wz = wxyz["wz"]; // x <- w, y <- zBut whatever. You can always stick to using
IEnumerables if you want.No More
*.AbstractI got rid of all the
Abstractnamespaces, since they don't really make much sense in the grand scheme of things. They've all been moved to the namespace that applies to them most (eg.INumberGroupwent toNerd_STF.Mathematics,ICombinationIndexerwent toNerd_STFsince it applies to more than just mathematics).The
FractionTypeThis type originally went under the name of
Rationalin Nerd_STF 2.x, but that name is actually incorrect, right? So in the rework, it changed names. But it also can do much more now thanks to theINumberinterface added in .NET 7.0. If you're using that framework or above, the fraction type is fully compatible with that type, and all the math functions inMathEand elsewhere that useINumberwill work with it.Can I just say that the
INumberinterface is really annoying to write a type for? There's so many weird casting functions and a whole lot of methods that even the .NET developers will hide in public declarations. Why have them at all?
And I want to change the name of the
MathEclass. I'm thinkingMath2, but I'm open to suggestions.And Best of All, Matrices
Oh yeah, we're adding those things again. I haven't completed (or even started) the dynamic
Matrixclass, that will arrive in beta3. But I have theMatrix2x2,Matrix3x3, andMatrix4x4fully implemented. TheToString()methods are much better with the new implementation than previously, and theGetHashCode()methods give different results even if the numbers have their positions swapped (which they originally didn't do).And it's much faster. Much, much faster. Don't get me wrong, multiplying a 4x4 matrix still requires 64 multiplications and 48 additions, which is quite a lot, but my original implementation was littered with many method calls, easily doubling the runtime. I have now super-inlined basically all of the static matrix code. And I mean, replacing all method calls with nothing but multiplication and addition for things like the determinants, the cofactors, the inverses, and more. Don't look at the source, it's really ugly.
That's all the major stuff in this update! I'll see you guys in beta3!
P.S. I know that the System library also includes
Vector2,Vector3, andVector4types. I'll add casting support for them soon.Downloads