matrix

Looping in a spiral

A friend was in need of an algorithm that would let him loop through the elements of an NxM matrix (N and M are odd). I came up with a solution, but I wanted to see if my fellow SO'ers could come up with a better solution. I'm posting my solution as an answer to this question. Example Output: For a 3x3 matrix, the output should be: (...

Binning in matlab

I have been unable to find a function in matlab or octave to do what I want. I have a matrix m of two columns (x and y values). I know that I can extract the column by doing m(:,1) or m(:,2). I want to split it into smaller matricies of [potentially] equal size and and plot the mean of these matricies. In other words, I want to put th...

Is there around a straightforward way to invert a triangular (upper or lower) matrix?

Hello, I'm trying to implement some basic linear algebra operations and one of these operations is the inversion of a triangular (upper and/or lower) matrix. Is there an easy and stable algorithm to do that? Thank you. ...

Better (non-linear) binning

The last question I asked concerned how to bin data by x co-ordinate. The solution was simple and elegant, and I'm ashamed I didn't see it. This question may be harder (or I may just be blind). I started out with about 140000 data points and split them into 70 groups equally spaced along the x axis I then took the average position (x...

Matrix artihmetic in PHP?

Hi, does anyone know of a library in PHP that handles matrix multiplication, inversion, etc.? I don't mind rolling my own, but I don't particularly fancy implementing inversion from scratch... Thanks, Ben ...

Problem using Math_Matrix PEAR library

Hi, I've not used PEAR before, and so I'm probably doing something dumb. I've installed the Math_Matrix library, but when I include it I just get an error. My entire code is this: <?php $path = '/home/PEAR/Math_Matrix-0.8.0'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); include_once 'Matrix.php'; ?> The error ...

Matrix arithmetic in PHP again

Hi, I recently asked a question about matrix libraries in PHP. I went with the suggestion of using the Math_Matrix PEAR library. However, it turns out that this library is out of date (meaning I had to change some of the code in the library to make it work with my version of PHP), and it doesn't really do what I need (e.g., it won't le...

How to reset to identity the "current transformation matrix" with some CGContext function?

I'm doing a series of translations and rotations on the CTM and at some point I need to reset it to identity before going further with transformations. I can't find any proper way to do it (obviously, there should have been a function named CGContextSetCTM or so) and since efficiency is the key, I don't want to use CGContextSaveGState/C...

How to specify an order for the columns in a matrix?

I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on. The problem I have is that SQL Reporting Services so...

Transforming an object between two coordinate spaces

So I'm reading the "3D Math Primer For Graphics And Game Development" book, coming from pretty much a non-math background I'm finally starting to grasp vector/matrix math - which is a relief. But, yes there's always a but, I'm having trouble understand the translation of an object from one coordinate space to another. In the book the a...

Matrix implementation benchmarks, should I whip myself?

Hello. I'm trying to find out some matrix multiplication/inversion benchmarks online. My C++ implementation can currently invert a 100 x 100 matrix in 38 seconds, but compared to this benchmark I found, my implementation's performances really suck. I don't know if it's a super-optimized something or if really you can easily invert a 200 ...

Getting flash.geom.Matrix3D rawData without requiring a Vector.<Number> allocation

Getting the "rawData" property from an instance of flash.geom.Matrix3D (a new class in Flash 10 for high-level 3D matrix math) causes a Vector. (also specific to Flash 10) object allocation to occur. Is there any way to access the raw data without incurring this object allocation overhead? Since I must access this data multiple times pe...

Can't use ImageSnapshot.captureBitmapData with a rotation matrix

Does anyone have an example of using the ImageSnapshot.captureBitmapData function with a rotation matrix? This is the code I'm using: var matrix:Matrix = new Matrix(); matrix.rotate(degreesToRadians(90)); var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(textInput, matrix); But unfortunately this throws an error on the follo...

Performance of Java matrix math libraries?

We are computing something whose runtime is bound by matrix operations. (Some details below if interested.) This experience prompted the following question: Do folk have experience with the performance of Java libraries for matrix math (e.g., multiply, inverse, etc.)? For example: JAMA: http://math.nist.gov/javanumerics/jama/ COLT: ...

Three dimensional matrices: practical usage

Other than graphics applications, what are some of the practical applications of 3d matrices? ...

What is SVD(singular value decomposition)

How does it actually reduce noise..can you suggest some nice tutorials? ...

How to check if m n-sized vectors are linearly independent?

Disclaimer This is not strictly a programming question, but most programmers soon or later have to deal with math (especially algebra), so I think that the answer could turn out to be useful to someone else in the future. Now the problem I'm trying to check if m vectors of dimension n are linearly independent. If m == n you can just bui...

Math (in WPF): Getting new x,y coordinates after a translation

With reference to this programming game I am currently building. I am using WPF to animate canvases, and I am using the BeginAnimation method to translate (move) a canvas across another canvas. With the BeginAnimation, I need to specify the From and To coordinates for both x and y, and this is the method I am using this like such: //X...

Custom Calculations in a Matrix - Reporting Services 2005

I am writing a report to show gas usage (in gallons) used by each department. The request is to view each month and the gallons used by each department. A column is required to display what each departments target goal is, based on the gallons of gas they have used in a past time frame. Each departments target goal is x percent less than...

How do I turn a table into a matrix?

If I got a table in a text file such like A B 1 A C 2 A D 1 B A 3 C D 2 A E 1 E D 2 C B 2 . . . . . . . . . And I got another symbol list in another text file. I want to transform this table into a Perl data structure like: _ A D E . . . A 0 1 1 . . . D 1 0 2 . . . E 1 2 0 . . . . . . . . . . But I only need some selected symbol...