FlappyBrain.Matrices
1.0.0
dotnet add package FlappyBrain.Matrices --version 1.0.0
NuGet\Install-Package FlappyBrain.Matrices -Version 1.0.0
<PackageReference Include="FlappyBrain.Matrices" Version="1.0.0" />
<PackageVersion Include="FlappyBrain.Matrices" Version="1.0.0" />
<PackageReference Include="FlappyBrain.Matrices" />
paket add FlappyBrain.Matrices --version 1.0.0
#r "nuget: FlappyBrain.Matrices, 1.0.0"
#addin nuget:?package=FlappyBrain.Matrices&version=1.0.0
#tool nuget:?package=FlappyBrain.Matrices&version=1.0.0
FlappyBrain.Matrices QuickStart Guide
FlappyBrain.Matrices is a complementary package to the NeuralFlapper library, providing essential matrix operations for neural network calculations. This guide will help you understand and use the matrix utilities.
Installation
Install the FlappyBrain.Matrices package via NuGet:
dotnet add package NeuralFlapperMatrices
Or via the NuGet Package Manager Console:
Install-Package NeuralFlapperMatrices
Basic Usage
Importing the Library
using FlappyBrain.Matrices;
Matrix Multiplication
// Create two matrices
double[,] matrixA = new double[,] {
{ 1, 2, 3 },
{ 4, 5, 6 }
}; // 2x3 matrix
double[,] matrixB = new double[,] {
{ 7, 8 },
{ 9, 10 },
{ 11, 12 }
}; // 3x2 matrix
// Multiply matrices
double[,] result = FlappyMatrix.MultiplyMatrix(matrixA, matrixB);
// Result is a 2x2 matrix
Scalar Multiplication
double[,] matrix = new double[,] {
{ 1, 2 },
{ 3, 4 }
};
// Multiply by scalar value
double scalar = 2.5;
double[,] result = FlappyMatrix.ScalarMultiplication(matrix, scalar);
// Result: { {2.5, 5.0}, {7.5, 10.0} }
Matrix Addition
double[,] matrixA = new double[,] {
{ 1, 2 },
{ 3, 4 }
};
double[,] matrixB = new double[,] {
{ 5, 6 },
{ 7, 8 }
};
double[,] result = FlappyMatrix.AddMatrix(matrixA, matrixB);
// Result: { {6, 8}, {10, 12} }
Matrix Subtraction
double[,] matrixA = new double[,] {
{ 10, 20 },
{ 30, 40 }
};
double[,] matrixB = new double[,] {
{ 5, 10 },
{ 15, 20 }
};
double[,] result = FlappyMatrix.SubtractMatrix(matrixA, matrixB);
// Result: { {5, 10}, {15, 20} }
Matrix Transposition
double[,] matrix = new double[,] {
{ 1, 2, 3 },
{ 4, 5, 6 }
}; // 2x3 matrix
double[,] transposed = FlappyMatrix.TransposeMatrix(matrix);
// Result is a 3x2 matrix: { {1, 4}, {2, 5}, {3, 6} }
Applying Operations to Matrices
The PerformOperation
method allows you to apply a custom operation to each element in a matrix using a delegate function.
// Define a custom operation
double SquareRoot(double value) => Math.Sqrt(value);
double[,] matrix = new double[,] {
{ 4, 9 },
{ 16, 25 }
};
// Apply the square root operation to each element
double[,] result = FlappyMatrix.PerformOperation(matrix, SquareRoot);
// Result: { {2, 3}, {4, 5} }
You can also use lambda expressions for inline operations:
double[,] matrix = new double[,] {
{ 1, 2 },
{ 3, 4 }
};
// Square each element
double[,] squared = FlappyMatrix.PerformOperation(matrix, x => x * x);
// Result: { {1, 4}, {9, 16} }
Printing Matrices
To visualize matrices for debugging or display purposes:
double[,] matrix = new double[,] {
{ 1.234, 5.678 },
{ 9.012, 3.456 }
};
string matrixString = FlappyMatrix.PrintMatrix(matrix);
Console.WriteLine(matrixString);
// Output:
// 1.23 5.68
// 9.01 3.46
Error Handling
The matrix operations include error checking for incompatible dimensions:
- Matrix multiplication requires the column count of the first matrix to match the row count of the second matrix
- Addition and subtraction require matrices of the same dimensions
When dimension requirements aren't met, the methods throw exceptions with descriptive error messages.
Support
For issues or questions, visit the GitHub repository: https://github.com/shinymajesty/flappybrain
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. 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. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FlappyBrain.Matrices:
Package | Downloads |
---|---|
FlappyBrain.Library
Small little neural network library for genetic algorithm |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 194 | 5/16/2025 |