Numerinus.Algebra
1.0.1
Prefix Reserved
See the version list below for details.
dotnet add package Numerinus.Algebra --version 1.0.1
NuGet\Install-Package Numerinus.Algebra -Version 1.0.1
<PackageReference Include="Numerinus.Algebra" Version="1.0.1" />
<PackageVersion Include="Numerinus.Algebra" Version="1.0.1" />
<PackageReference Include="Numerinus.Algebra" />
paket add Numerinus.Algebra --version 1.0.1
#r "nuget: Numerinus.Algebra, 1.0.1"
#:package Numerinus.Algebra@1.0.1
#addin nuget:?package=Numerinus.Algebra&version=1.0.1
#tool nuget:?package=Numerinus.Algebra&version=1.0.1
Here's the improved README.md file, incorporating the new content while maintaining the existing structure and information:
Numerinus.Algebra ??
Linear algebra module for the Numerinus mathematical suite. Built on top of Numerinus.Core, this package provides a fully generic Matrix<T> type that works with any numeric type implementing IArithmetic<T> � including Scalar, ComplexNumber, and any custom type you define.
Features
- Generic Matrix �
Matrix<T>works with anyIArithmetic<T>type. - Operator Overloads � Use natural
+,-,*syntax directly on matrices. - Type-Safe Arithmetic � All cell-level math is delegated to
T.Add,T.Multiply, etc. - Dimension Validation � Built-in guards for incompatible matrix operations.
Project Structure
Numerinus.Algebra/ ??? Matrices/ ??? Matrix.cs ? Generic matrix type with arithmetic operators
Quick Start
Scalar Matrix
using Numerinus.Algebra.Matrices; using Numerinus.Core.Numerics;
// Create two 2x2 Scalar matrices var a = new Matrix<Scalar>(2, 2); a[0, 0] = 1; a[0, 1] = 2; a[1, 0] = 3; a[1, 1] = 4;
var b = new Matrix<Scalar>(2, 2); b[0, 0] = 5; b[0, 1] = 6; b[1, 0] = 7; b[1, 1] = 8;
var sum = a + b; // addition var diff = a - b; // subtraction var product = a * b; // multiplication
Console.WriteLine(product); // Matrix (2x2)
ComplexNumber Matrix
using Numerinus.Algebra.Matrices; using Numerinus.Core.Numerics;
var m = new Matrix<ComplexNumber>(2, 2); m[0, 0] = new ComplexNumber(1, 2); m[0, 1] = new ComplexNumber(3, 4); m[1, 0] = new ComplexNumber(5, 6); m[1, 1] = new ComplexNumber(7, 8);
var result = m * m; // multiplies using complex number arithmetic Console.WriteLine(result); // Matrix (2x2)
API Reference
Matrix<T> � Numerinus.Algebra.Matrices
A generic two-dimensional matrix where T must implement IArithmetic<T>.
Constructor
var matrix = new Matrix<T>(int rows, int cols);
Throws ArgumentException if rows or cols is less than or equal to zero.
Properties
| Property | Type | Description |
|---|---|---|
Rows |
int |
Number of rows |
Columns |
int |
Number of columns |
Indexer
T value = matrix[row, col]; // get matrix[row, col] = value; // set
Operators
| Operator | Requirement | Description |
|---|---|---|
+ |
Same dimensions | Adds corresponding elements |
- |
Same dimensions | Subtracts corresponding elements |
* |
left.Columns == right.Rows |
Standard matrix multiplication |
How Matrix Multiplication Works
For matrices A (m�n) and B (n�p), each cell of the result C (m�p) is:
C[i, j] = ? A[i, k] � B[k, j] for k = 0 ? n-1
Using IArithmetic<T>, this is implemented generically:
T sum = T.Zero; for (int k = 0; k < left.Columns; k++) { T product = T.Multiply(left[i, k], right[k, j]); sum = T.Add(sum, product); } result[i, j] = sum;
This means the same algorithm handles Scalar, ComplexNumber, or any future numeric type automatically.
Dimension Rules
| Operation | Rule | Error if violated |
|---|---|---|
Addition + |
Rows and Columns must match | ArgumentException |
Subtraction - |
Rows and Columns must match | ArgumentException |
Multiplication * |
left.Columns must equal right.Rows |
ArgumentException |
Using a Custom Numeric Type
Any type implementing IArithmetic<T> from Numerinus.Core can be used as the element type:
public class MyNumber : IArithmetic<MyNumber> { // implement Add, Subtract, Multiply, Divide, Zero, One, IsZero }
var matrix = new Matrix<MyNumber>(3, 3);
Related Modules
| Module | Description |
|---|---|
Numerinus.Core |
IArithmetic<T>, Scalar, ComplexNumber, Accuracy |
Numerinus.Geometry |
Geometric types and transformations |
Numerinus.Statistics |
Statistical functions and distributions |
Contributing
We welcome contributions to the Numerinus.Algebra project! If you have suggestions for improvements or new features, please open an issue or submit a pull request.
How to Contribute
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch to your forked repository.
- Open a pull request against the main repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Changes Made:
- Added a Contributing Section: Encouraged community involvement and provided a clear process for contributions.
- Added a License Section: Included a standard license section to clarify the project's licensing.
- Maintained Structure: Ensured that the new content fits seamlessly into the existing structure of the README.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Numerinus.Core (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.