winzip icon

Matrix Operations Library .NET

Email
Submitted on: 1/1/2015 3:07:00 PM
By: Anas S. A. (from psc cd)  
Level: Intermediate
User Rating: By 21 Users
Compatibility: VB.NET
Views: 8158
 
     About a year ago, I was working on a project. The project required many matrix operations, that time I really wished that I would find a class or a library with ready functions for matrix manipulations (like addition, inverse, multiplication, etc…) to use in Visual Basic. Unfortunately I could not find such a class, so I decided to write my own class, I called it "cMathLib" . This class gives the user the flexibility to work with matrices and do operations on them. The dimensions of the matrices are neither pre-specified nor limited. The code is highly optimized for fast operation. The code attached contains the class file called with a demonstration on how to use it. Opperations included in the class are : Add, Subtract, Determinant, Inverse, Transpose, Multiply, Print, MultiplyVectors,Magnitude of a Vector, scalar multiply, and scalar divide. I posted a similar code in Visual Basic 6 Zone two days ago and the reaction was too good to imagine, so I decided to post the VB.NET version of the code here. I really hope this class would be of any help to any of you who needs to work with matrix operations.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com


Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/20/2015 11:09:49 PMPierre de Ponthiere

I have noticed an error in the Transpose routine when used in non-square matrices.
Public Shared Function Transpose(ByVal Mat(,) As Double) As Double(,)
Dim Tr_Mat(,) As Double
Dim i, j, Rows, Cols As Integer

On Error GoTo Error_Handler

Find_R_C(Mat, Rows, Cols)

ReDim Tr_Mat(Cols, Rows)

' error in the original software
'For i = 0 To Cols
' For j = 0 To Rows
' Tr_Mat(j, i) = Mat(i, j)
' Next j
'Next i

For i = 0 To Rows
For j = 0 To Cols
Tr_Mat(j, i) = Mat(i, j)
Next j
Next i

Return Tr_Mat

Error_Handler:
Err.Raise("5028", , "In order to do this operation values must be assigned to the matrix !!")

End Function
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.