Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 matrix

Author  Topic 

remonis
Starting Member

1 Post

Posted - 2012-03-08 : 04:00:52
looking for some SQL code to:
- transpose a matrix (roughly 60*60)
- multiply matrix by another matrix
- inverse a matrix
the program language I use can encapsulate SQL code.and the tool i used does not have those functions as basic functions.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-08 : 09:19:21
Depending on how you have stored the matrix in SQL tables:

a) Transposing may be as simple as transposing the row number and column number in your query.

b) Multiplication is relatively simple too, depending on how you stored it. Take a look at this article: http://www.simple-talk.com/sql/t-sql-programming/sql-server-matrix-workbench/

c) Matrix inversion is a whole different thing. I have never tried this in SQL. Since the computational requirements are O(3), how you do it depends on the size of the matrix, how sparse it is etc. I am unable to offer any useful suggestions - hopefully someone else will.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-03-08 : 09:49:24
Keep in mind that SQL is not a general purpose programming language and is not intended for such operations. You are better off using another language like C/C++/C#, or invoking the Excel object model via COM to do these kinds of operations.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-08 : 10:14:09
I would have implemented it using CLR proc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -