Answered # How to solve matrix in VB.NET

Mitja Bonca 557 codeorder 197 Discussion Starter zhouy 5 Discussion Starter zhouy 5 Mitja Bonca 557 Discussion Starter zhouy 5 Discussion Starter zhouy 5 Featured Reply Reverend Jim 1,410 Discussion Starter zhouy 5 Discussion Starter zhouy 5 Featured Reply MonsieurPointer 27 Discussion Starter zhouy 5 OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...

0

have you heard of multidimensional arrays?

This is the answer here.

btw, how do we get those results (any formulas)?

0

Not a math.wiz, just hobbyist programmer, and am just wondering; How are the calculations added up to return those results?

.ex: "C=0.4857143", though how are you getting that value?

0

.ex: "C=0.4857143", though how are you getting that value?

Thanks dear,

I am not a programmer doing as a hobby. I am developing a mathematical software for Ecology. I am not much familiar with matrix and solving it in VB. Unfortunately my ecology model gives some answers as matrices. So, I want to solve those using VB.NET codes as I do my codes in VB.NET. I posted here just an example, not a real data. These results I got using "R" statistical software. Here are the codes for "R" software.

> e<- matrix(nrow=3, ncol=3, data=c(5,0,10,0,10,10,10,0,34))

> f<- c(1,0,0)

> solve(e,f)

[1] 0.4857143 0.0000000 -0.1428571

>

But this is very difficult in VB.NET. That's why I posted this into this forum.

Please help me!

Thanks!

0

This is the answer here.

btw, how do we get those results (any formulas)?

Thanks dear,

Yes I heard multidimensional arrays. But I am not much familiar with it in VB.NET. Okay, I will try to do it with it. Thanks, but I must say this. I am developing a mathematical software for Ecology. I am not much familiar with matrix and solving it in VB. Unfortunately my ecology model gives some answers as matrices. So, I want to solve those using VB.NET codes as I do my codes in VB.NET. I posted here just an example, not a real data. These results I got using "R" statistical software. Here are the codes for "R" software.

> e<- matrix(nrow=3, ncol=3, data=c(5,0,10,0,10,10,10,0,34))

> f<- c(1,0,0)

> solve(e,f)

[1] 0.4857143 0.0000000 -0.1428571

>

But this is very difficult in VB.NET. That's why I posted this into this forum.

Please help me!

Thanks!

0

You still didnt tell us any formula you want to use to get these kindof results.

Here is how you create and loop through multidimensional array:

```
Dim multiArray As Integer(,) = New Integer(,) {{5, 0, 10}, {0, 10, 0}, {10, 0, 34}}
Dim x As Integer = 0
For i As Integer = 0 To multiArray.GetLength(0) - 1
For j As Integer = 0 To multiArray.GetLength(1) - 1
x = multiArray(i, j)
Next
Next
```

*Edited 4 Years Ago by Mitja Bonca*: Thx codeorder for letting me know :)

0

Many thanks Mitja Bonca,

But how i solve C, D and E using these kind of multidimensional arrays? Formula?? OK, This is basics of least square methods. When we solve matrix like this, we get 3 equations (using above matrix) like,

5C + 0 + 10E = 1

0 + 10D + 0 = 0

10C + 0 + 34E = 0

This I got just by multiplying the matrix elements. So just we can solve manually and get C, D and E. Also it is easy using R software (as I mentioned codes in previous reply). This is what I ask. But, why this is difficult in VB.NET??? Can you extend your codes to get answers for C, D and E.

Thanks!

0

I cannot help you out, since I dont know what would those C, D and E mean.

Thanks for the discussion.

1

I think the technique you want to use is called Gaussian Elimination. I must have written this code a half dozen times when I was back in university. I did versions with simple elimination, partial and full pivoting (actual and virtual). I hated it every time and I have long since forgotten how to do it but a walk-through with code can be found here. The technique can be used to solve for n equations in n unknowns.

And don't get me started on eigen values or linear diophantine equations. I don't recall what they are for but it is cool to be able to rattle off the names. Of course I didn't think so at exam time;)

Trivia - for matrices that are non-singular, the computer language, APL, has a single operator (quad divide) that does all that for you.

*Edited 4 Years Ago by Reverend Jim*: n/a

1

Dear codeorder and Mitja Bonca,

Thanks for your discussion about my problem. I solved the problem using C# library for .NET. Here you can find it, but its in another forum. I just used "solvelinear()" function. Its easy. I use two projects, one for C# and one for VB in same solution. Its working, but i don't know what will happen in the setup deployment.

Thanks!

0

I think the technique you want to use is called Gaussian Elimination. I must have written this code a half dozen times when I was back in university. I did versions with simple elimination, partial and full pivoting (actual and virtual). I hated it every time and I have long since forgotten how to do it but a walk-through with code can be found here. The technique can be used to solve for n equations in n unknowns.

And don't get me started on eigen values or linear diophantine equations. I don't recall what they are for but it is cool to be able to rattle off the names. Of course I didn't think so at exam time;)

Trivia - for matrices that are non-singular, the computer language, APL, has a single operator (quad divide) that does all that for you.

Thanks for the information. I will try it also. My problem is already solved using C# libraries for Matrix (see my previous reply. Thanks!

1

C, D, and E are unknowns. What is presented is what is known as "simultaneous equations" (**system of linear equations**). Basically, you want to multiply, add, and subtract, etc, until the matrix on the left hand side ends up as the identity matrix:

[1 0 0]

[0 1 0]

[0 0 1]

Whatever is performed on the left matrix must also be performed on the right matrix. Once you have come to the point where you have the identity matrix on the left side, the right side will display the results to C, D, and E.

This link (http://www.ucl.ac.uk/Mathematics/geomath/level2/mat/mat102.html) should get you started.

0

C, D, and E are unknowns. What is presented is what is known as "simultaneous equations" (

system of linear equations). Basically, you want to multiply, add, and subtract, etc, until the matrix on the left hand side ends up as the identity matrix:[1 0 0]

[0 1 0]

[0 0 1]Whatever is performed on the left matrix must also be performed on the right matrix. Once you have come to the point where you have the identity matrix on the left side, the right side will display the results to C, D, and E.

This link (http://www.ucl.ac.uk/Mathematics/geomath/level2/mat/mat102.html) should get you started.

Thanks!

This question has already been answered. Start a new discussion instead.

Recommended Articles

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

btn_addline :

`Private Sub btn_addline_Click(ByVal ...`

I don’t want at this stage work on a big separate project as I've already got plenty ...