Solved

Matrix operations in VB

Posted on 2001-08-02
12
1,275 Views
Last Modified: 2007-12-19
I need code to do some matrix opperations (I assume you know what matrixes are. I am talking about in math)

I need code to do the following (MUST be for matrixies of any size)

*Add, subtract, multiply
*find inverses (matrix^-1)
*find determinates
0
Comment
Question by:BenBen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
12 Comments
 
LVL 3

Expert Comment

by:leojl
ID: 6347190
hi ben
1 matrix, 2 matrices.

Excel2000 spreadsheet will do matrix math for you.

Is this a homework assignment?

leo
0
 
LVL 28

Expert Comment

by:Ark
ID: 6347206
Hi

http://www.freevbcode.com/ShowCode.Asp?ID=2944

>>This program performs the following operations on real or complex matrices:

Addition
Subtraction
Multiplication
Scalar Multiplication
Scalar Division
Determinant & Inverse
Solution Set<<

http://www.freevbcode.com/ShowCode.Asp?ID=132

>>Matrix operations (addition, subtraction, and multiplication)<<

Cheers
0
 
LVL 1

Author Comment

by:BenBen
ID: 6349244
nope not homework, curocity.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Author Comment

by:BenBen
ID: 6349256
Ark, Thank you for the code, its gonna take me a little to look over :)
0
 
LVL 1

Author Comment

by:BenBen
ID: 6349590
ARK:

According to the documentation in the code this only works with up to "10x10 matrices" which dosent fit the description "matrices of all sizes" However i still think your answer deservers points. Because I do not want to put a "C" on your answering record, I would like to post a new "Question" with a value of 100 pts, and give you an "A". Is this acceptiable to you?
0
 
LVL 28

Expert Comment

by:Ark
ID: 6350893
Hi
Just change
Public Const MAXMATRIXSIZE As Integer = 10
to any size you want, ie
Public Const MAXMATRIXSIZE As Integer = 1000

Some more links:
Transpose matrix of any size (matrix^-1):
http://www.vb2themax.com/Item.asp?PageID=CodeBank&Cat=130&ID=295
Multiplication of any size (sample for 1000x1000)
http://www.planet-source-code.com/xq/ASP/txtCodeId.24468/lngWId.1/qx/vb/scripts/ShowCode.htm

Cheers
0
 
LVL 1

Author Comment

by:BenBen
ID: 6350903
are you sure that works, why would they put that in anyways
0
 
LVL 28

Accepted Solution

by:
Ark earned 200 total points
ID: 6350950
Works fine. The only prb is weired FlexGrid positioning.
Change also
Public Const CELLWIDTH As Integer = 800
and in modMSGridRoutines in PrepareForm Function change this:
    If M1.Rows >= 8 Or M1.Cols >= 6 Or M2.Rows >= 8 Or M2.Cols >= 6 Then
        G1.Width = MAXCDW * CELLWIDTH + 100
        G1.Height = MAXCDH * CELLHEIGHT + 100
        G1.ScrollBars = flexScrollBarBoth
'********** added *********************        
        G2.Left = G1.Width + 4 * SPACER
        L2.Left = G2.Left
        L2.Width = G2.Width
        L2.Caption = M2.Name
'********** added *********************        
        G2.Width = MAXCDW * CELLWIDTH + 100
        G2.Height = MAXCDH * CELLHEIGHT + 100
        G2.ScrollBars = flexScrollBarBoth
    End If

BTW, one more link

http://www.planet-source-code.com/xq/ASP/txtCodeId.23648/lngWId.1/qx/vb/scripts/ShowCode.htm
0
 
LVL 3

Expert Comment

by:leojl
ID: 6351080
the man in the street does not often have a pressing need to multiply or otherwise manipulate matrices. is there a real world need related to this question or is it an end in itself?

i am starting to make a study of stock options
(msft mostly) and i may use some matrices as a part of the analysis.... so some of the links given  may be of real use to me.

leo
0
 
LVL 1

Author Comment

by:BenBen
ID: 6351366
supose you have an sysetm of equasions,

x + y + z = 5
5x - 2y -3z = 50
x - 8y -40 = 80

Now, what if you use a matrix to solve this

|1   1   1|  |x|      | 5 |
|5  -2  -3|  |y|  =   |50 |
|x  -8 -40|  |z|      |80 |
     ^        ^         ^
    mA        mB        mC

ok now
(mA)(mB) = mC
(mA)(mA^1)(mB) = (mC)(mA^-1)
(mB)= (mC)(mA^-1)

(this will all look better when its monospaced)
0
 
LVL 3

Expert Comment

by:leojl
ID: 6351764
typo...1 for tne x at lower left.
0
 
LVL 1

Author Comment

by:BenBen
ID: 6396861
the reason for the b is because it proforms slower then my TI83 with big numbers. Oh well
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question