FlappyBrain.Matrices 1.0.0

dotnet add package FlappyBrain.Matrices --version 1.0.0
                    
NuGet\Install-Package FlappyBrain.Matrices -Version 1.0.0
                    
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="FlappyBrain.Matrices" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlappyBrain.Matrices" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FlappyBrain.Matrices" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlappyBrain.Matrices --version 1.0.0
                    
#r "nuget: FlappyBrain.Matrices, 1.0.0"
                    
#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.
#addin nuget:?package=FlappyBrain.Matrices&version=1.0.0
                    
Install FlappyBrain.Matrices as a Cake Addin
#tool nuget:?package=FlappyBrain.Matrices&version=1.0.0
                    
Install FlappyBrain.Matrices as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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