Skip to main content

Posts

Showing posts from March, 2018

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. Rememb

Arrays for matrices

Since, engineers are mostly operating on algebraic operations the introduction to arrays and lists is needed. There is several types of the arrays in the C#. I will try show the most useful for me. In general the arrays and lists are used to store the data. I will try to show in easy way to how initialize the arrays. 1D array For engineer can be understand as a vector. To defined the vector you need to declare the type name and size: Type [ ] name = new Type [ size ]{ element_1, element_2, element_3, ... , element_size } ; Let's say we need a 1D array of 4 double type numbers.   double [ ]  array1 =  new double [4]{ 1.02 , 2.32 , 0.000021 , 23123.3213} ; The other way to declare the array is to put the elements in separate lines. Type []   name  =  new  Type [ size ] ; name [0] = element_1 ; name [1]  = element_2 ; name [2]  = element_3 ; ... name [size-1]  = element_size ; The example: double [ ]  array1 =  new  double [4]; array1 [0]  = 1.02; array1 [1