mathnet-numerics

How to create a submatrix skipping a row and a column using Mathnet.numerics library?

妖精的绣舞 提交于 2020-01-06 06:43:46
问题 I am trying to code to obtain minors of different elements in a matrix. I am using Mathnet.numerics library. I see the library has submatrix method where I need to input rowindex and rowcount. But for my case I need to create submatrix by skipping rows and columns (for example, for a 3x3 matrix, for element (1,2), I need to skip the first row and second column to create my submatrix). Any idea how to use the existing functionality of the Mathnet.numerics? 回答1: You can use RemoveRow and

How to create a submatrix skipping a row and a column using Mathnet.numerics library?

大憨熊 提交于 2020-01-06 06:42:05
问题 I am trying to code to obtain minors of different elements in a matrix. I am using Mathnet.numerics library. I see the library has submatrix method where I need to input rowindex and rowcount. But for my case I need to create submatrix by skipping rows and columns (for example, for a 3x3 matrix, for element (1,2), I need to skip the first row and second column to create my submatrix). Any idea how to use the existing functionality of the Mathnet.numerics? 回答1: You can use RemoveRow and

Math.Net Numerics - Fitting sinus function

情到浓时终转凉″ 提交于 2019-12-23 15:34:42
问题 I'm new here and I hope that perhaps the experts outthere can help me: I want to fit the sinus function f(x) = a *sin(b* (x+c))+d via the library "math.net numerics" in C#. At the beginning I tried the following example code: // data points: we compute y perfectly but then add strong random noise to it var rnd = new Random(1); var omega = 1.0d var xdata = new double[] { -1, 0, 0.1, 0.2, 0.3, 0.4, 0.65, 1.0, 1.2, 2.1, 4.5, 5.0, 6.0 }; var ydata = xdata.Select(x => 5 + 2 * Math.Sin(omega*x + 0

How to refactor code to make it functional style?

▼魔方 西西 提交于 2019-12-19 09:46:54
问题 Playing with F#, I'm trying to think of code in a more functional way. A large part of my work happens to be numerical in nature so I'm thinking whether this re-education makes sense. Is writing numerical code in a functional way like trying to fit a square peg in a round hole or is it simply a matter of a steep learning curve irrespective of the application? For example, lets take a snippet which demonstrates the weak law of large numbers: open System open System.IO open System.Windows.Forms

Multiple Regression with math.net

自作多情 提交于 2019-12-12 01:29:29
问题 Hello I am trying to get multiple regression with math.net and I am a little confused. var xdata = new DenseMatrix( new double[,]{{1, 36, 66, 45, 32}, {1, 37, 68, 12, 2}, {1, 47, 64, 78, 34}, {1, 32, 53, 56, 32}, {1, 1, 101, 24, 90}}); var ydata = new double[] { 15, 20, 25, 55, 95 }; var X = DenseMatrix.CreateFromColumns(new[] { new DenseVector(xdata.Length, 1), new DenseVector(xdata) }); var y = new DenseVector(ydata); var p = X.QR().Solve(y); var a = p[0]; var b = p[1]; I guess I don't

Right Matrix Division in C#

偶尔善良 提交于 2019-12-08 03:54:48
问题 How can I perform a Right Matrix Division in C#?. In MATLAB the code would be AA(I) = ((X(I,:)-mu)/si)*(X(I,:)-mu)'; %where, %I is index %AA is a matrix of 1330x1 double %X is a matrix of 1330x158 double %mu is a matrix of 1x134 double %si is a matrix of 134x134 double For now I am using jagged arrays to perform all my computations. Is there a library I should use that can do efficient matrix computations? Update with using MathNet LinearAlgebra /* MathNet Matrix tests */ Matrix<double> AA =

Parallel.For not utilising all cores

丶灬走出姿态 提交于 2019-12-01 14:43:52
问题 I'm doing heavy mathematical computations using Math.Net Numerics parallely inside Parallel.For block. When I run code in my local system with 4 cores(2*2), it's using all 4 cores. But when I run same code in our dev server with 8 cores(4*2), it's using only 4 cores. I've tried setting MaxDegreeOfParallism,but couldn't help. Any idea why all cores are not being utilised. Below is sample code. Parallel.For(0,10000,(i)=> { // heavy math computations using matrices }); 回答1: From MSDN By default,

How to refactor code to make it functional style?

≡放荡痞女 提交于 2019-12-01 08:58:56
Playing with F#, I'm trying to think of code in a more functional way. A large part of my work happens to be numerical in nature so I'm thinking whether this re-education makes sense. Is writing numerical code in a functional way like trying to fit a square peg in a round hole or is it simply a matter of a steep learning curve irrespective of the application? For example, lets take a snippet which demonstrates the weak law of large numbers: open System open System.IO open System.Windows.Forms open System.Windows.Forms.DataVisualization open FSharp.Data open FSharp.Charting open FSharp.Core