Skip to main content

Matrices from arrays

The array is not exactly matrix. You can't make any mathematical operations on it. You can although make operations on the elements of the matrices. Of course to multiply two arrays with each other you can write your own scripts, but fortunately (like always ;) ) somebody already make it. You will find many math libraries allowing to implement algebraic operations. In this post I will show how to install in your VS one of them. I will be using NuGet packages, which by default you will find in your VS 2017 community.

First create new project and go for the solution explorer window. Right click on ProjectName and go for Manage NuGet Packages.


The Nuget will open. Please click browse in the left top, type mat and search for mathematical libraries.



Install MathNet numeric, go back to your c# code. Everything is now ready to start using MathNet library.

https://www.mathdotnet.com/

Initialize two arrays of size 2x2 and tr to multiply them using MathNet.

Remember about adding library by typing:  
using MathNet.Numerics.LinearAlgebra ;
in heading of the code

Comments

Popular posts from this blog

Finite Element Method Programming - 1D bar element, C# methods, C# loops

On the previous post, we established 1D bar finite element. This time we will go more into the programming in C# and try to make some automation in our code. I will try to explain: - loops: for - methods in C# - arrays 1D and 2D In the beginning, we have to build a task for us, to not feel that we are losing time. So, let's imagine that we want to check the result for the same bar, but with several divisions. For example: Does the result will change if I will create 2 finite elements instead of 1? The beginning of the code will be looking the same: namespace FEM1d_basic_1 {      class Program     {          static void Main(string[] args)         {              // The heading of the code              Console .WriteLine("FEM 1D program for bar");             // The variables        ...
How to write C# components in Visual Studio for Grasshopper? If you have the Visual Studio community 2017, you have to also download assembler for grasshopper v6. https://marketplace.visualstudio.com/items?itemName=McNeel.GrasshopperAssemblyforv6 After downloading the file, start it. The VS community 2017 should be chosen automatically. Now you can start VS 2017 one more time, in the new project, you should find new options: If you choose Visual C# > Rhinoceros > Grasshopper Add-on for v6, a new window will appear: The missing files have to be added to references. The RhinoCommon and Rhino.exe you will probably find somewhere on C disc (in my case it is C:\Program Files\Rhinoceros 5 (64-bit) ). The Grasshopper.dll file location you should check on your disc through searching enginge ( in my case it was :  C:\Program Files\Common Files\McNeel\Rhinoceros\5.0\Plug-ins\Grasshopper (b45a29b1-4343-4035-989e-044e8580d9cf)\0.9.76.0 ). Click finish and new empty cod...

Finite Element Method Programming - Introduction

The problem with finite element analysis learning is that everybody is starting it from theory and after you are completely brainwashed, they start doing practical calculations. The theory for today FEM is so wide, that when you go for this super interesting practical case and you finally will apply your FE knowledge, suddenly ... it occurs you just do not remember theory...  My approach here will be a little bit different. I will start explanation from a simple practical case, and I will be coming back to theory during the explanation. In this post, I will show 1D bar element and the method of basic programming it in C#. I assume you want to learn C# and FEM so I will try to say about both of them simultaneously. First thing first! The task is to calculate 1D bar, like on this figure: For simplification, we assumed: this is simple bar element, only compression or tension is allowed, there is no gravity, the deformation can be only according to the one directio...