Nerd_STF 3.0.0-beta3

This is a prerelease version of Nerd_STF.
dotnet add package Nerd_STF --version 3.0.0-beta3                
NuGet\Install-Package Nerd_STF -Version 3.0.0-beta3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nerd_STF" Version="3.0.0-beta3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nerd_STF --version 3.0.0-beta3                
#r "nuget: Nerd_STF, 3.0.0-beta3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nerd_STF as a Cake Addin
#addin nuget:?package=Nerd_STF&version=3.0.0-beta3&prerelease

// Install Nerd_STF as a Cake Tool
#tool nuget:?package=Nerd_STF&version=3.0.0-beta3&prerelease                

Nerd_STF

Nerd_STF is a multi-purpose library for .NET focused primarily on mathematics. It supports basically all versions of .NET has plenty of flexibility to let you do what you please with it.

Contents

Examples

Here's how to derive a polynomial in Nerd_STF:

using Nerd_STF.Mathematics.Equations;

Polynomial poly = new(2, 1, 3); // 2x^2 + x + 3
Polynomial derivative = poly.Derive();

Console.WriteLine(derivative);  // Output: 4x + 1

Here's how to get or set part of a number group:

Float3 xyz = (1, 2, 3);

Float2 xy = new(xyz["xy"]);
Float2 zy = new(xyz["zy"]);
double[] yxzy = [.. xyz["yxzy"]];

xyz["yz"] = [7, 8];
Console.WriteLine(xyz); // Output: (1, 7, 8)

Pretty easy, right?

How to Install

NuGet

You can install the package very easily with the NuGet Package Manager. The link to its NuGet page is here. You could install it by running a command:

# Do not include version flag to download the latest release.
dotnet add package Nerd_STF --version 3.0

or by including a package reference element in your project file:


<PackageReference Include="Nerd_STF" Version="3.0" />

Manual Reference

You could also manually reference the DLL for the project. Go to the releases page and select the library version and .NET target of your choice. At the time of writing, this project compiles to .NET Standard 1.3, 2.1, and .NET 7.0, but more may be added in the future.

Place the DLL somewhere you'll be able to reference later.

If you're using Visual Studio 2019 or 2022:

  • Right click the project icon in the hierarchy.
  • Go to Add > Project Reference
  • Click Browse and locate the DLL you saved earlier.
  • Click OK. You should be good to go!

Otherwise, you'll have to add a project reference element in your project file somewhere.

<Reference Include="Nerd_STF">
  <HintPath>path\to\your\download\Nerd_STF.3.0.NET7.0.dll</HintPath>
</Reference>

I found a bug!

I'm not surprised, I'm only one guy. Feel free to make an issue in the repository and I'll get to it when I can!

I'd like to contribute!

Well, I'd prefer to do most of the programming myself, but if anyone wants to submit a pull request, feel free! Stick to the version-specific branches, try not to make commits on the main branch.

When's your next release?

No idea. This is a pet project, so progress on this library will come and go. It was more than a year between versions 2.4.1 and 3.0. It's really whenever mood strikes, so just watch the project to see what the current status is.

Older Versions

3.0 has plenty of breaking changes from 2.4.1 (and the rest of the 2.x updates), so it's totally fine if you don't want to update. I'll keep the 2.x updates up for the long-term, no reason to remove them. As for the versions before 2.0, well, it wasn't even really a library at that point. Do with it what you will.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.1 is compatible.  netstandard1.2 was computed.  netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 is compatible. 
.NET Framework net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0-beta3 52 2/19/2025
3.0.0-beta2 89 11/25/2024
3.0.0-beta1 82 10/29/2024
2.4.1 265 7/17/2023
2.4.0 181 7/10/2023
2.3.2 279 3/9/2023
2.3.1.68 374 11/12/2022
2.3.1.52-alpha 247 10/31/2022 2.3.1.52-alpha is deprecated because it has critical bugs.
2.3.1.39-alpha 207 9/30/2022 2.3.1.39-alpha is deprecated because it has critical bugs.
2.3.0 444 8/2/2022
2.2.0 460 6/10/2022
2.1.2 459 5/2/2022
2.1.1 421 4/17/2022
2.1.0 441 4/17/2022
2.0.1 454 4/3/2022
2.0.0 442 4/3/2022

# Nerd_STF v3.0-beta3

Nerd_STF 3.0 is approaching a stable release, but I've still got some things that I still want to add and things that I feel like are unsatisfactory. So here's another beta release. There will probably only be one or two more before a final version is ready. This is easily the most ambitious project I've done in such a small amount of time, so I think you can bear with me as I bring this part of it to completition.

Here's what's new:

## `Fill<T>` and `Fill2d<T>` are back!

I thought the `Fill<T>` delegate was slightly redundant, since you could probably just pass an `IEnumerable` or something instead, but I've learned that it's really easy to pass a Fill delegate in places where an IEnumerable would be annoying. I might add support for Fill stuff in the future, such as an extension list, but for now I've just re-added the delegate and made most types support it in a constructor.

## Slight Matrix Constructor Change

I think I got the meaning of the `byRows` parameter mixed up in my head, so I have swapped its meaning to what it (I think) should be. The default value has also changed, so unless you've been explicitly using it you won't notice a difference.

## And Best of All: Colors!

I have had plenty of time to think about how I could have done colors better in the previous iteration of the library, and I've come up with this, which I think is slightly better.

First of all, colors derive from the `IColor<TSelf>` interface similarly to how they did before, but no more `IColorFloat`. Now, every color has double-precision channels by default. To handle specific bit sizes, the `IColorFormat` interface has been created. It can of course be derived from, and I think it's pretty easy to use and understand, but hopefully there will be enough color formats already defined that you won't even need to touch it directly. At the moment, there's only one real color format created, `R8G8B8A8`, which is what it sounds like: 8 bits for each of the RGBA channels. There will be plenty more to come.

I have been thinking about writing a stream class that is capable of having a bit-offset. I would use it in tandom with the color formats, as many of them span multiple bytes in ways that don't always align with 8-bit bytes. It seems somewhat out of place, but I think I'll go for it anyway.

There's also a color palette system now. You give it a certain number of colors and it allocates room to the nearest power of two. If you give it 6 colors, it allocates room for 8. This is to always keep the size of the palette identical to its bit depth. 6 colors needs 3 bits per color, so might as well do as much as you can with those 3 bits.

There is also an `IndexedColor` "format," which does not store its color directly. Rather, it stores its index and a reference to the color palette it came from. I understand a true "indexed color" wouldn't store a reference to its palette to save memory, but this is mostly for ease of use. Colors are passed through methods with the `ref` keyword, so you can manipulate them directly.

```csharp
void MethodA()
{
   ColorPalette<ColorRGB> palette = new(8);

   // palette[3] is currently set to black.
   MethodB(palette[3]);
   // palette[3] is now set to blue.
}

void MethodB(IndexedColor<ColorRGB> color)
{
   color.Color() = ColorRGB.Blue;

   // You could also:
   ref ColorRGB val = ref color.Color();
   val = ColorRGB.Blue;
}
```

Anyway, that's all I've got for now. I'm not sure what will be next up, but here's what's left to do:
- Complex numbers and quaternions.
- More color types and formats.
- Bit-offset compatible streams.
- Fix bugs/inconveniences I've noted.

I think the Image type will be completely reworked and might be what version 3.1 is.