matrix

First column of a matrix given as a list of rows in Haskell

If I have a matrix given as a list of rows [[1,2,3],[4,5,6]], I want to return the first column, [1,4]. I'm an absolute beginner in Haskell and I have no idea on even how to deal with nested lists. ...

MATLAB: Extract multiple parts of a matrix without using loops

Hi, I have a huge 2D matrix and I would like to extract 15 different 100x100 parts out of it. I have two vectors x and y where the top left indices of the parts are saved. I have used something like this: result = cam1(x(1:end):(x(1:end)+99), y(1:end):(y(1:end)+99)); but the result is just a 100x100 matrix instead of a 15x100x100. Wh...

Storing information on points in a 3d space

I'm writing some code (just for fun so far) in Python that will store some data on every point in a 3d space. I'm basically after a 3d matrix object that stores arbitary objects that will allow me to do some advanced selections, like: Get the point where x=1,y=2,z=3. Getting all points where y=2. Getting all points within 3 units of po...

Unprojecting an on screen point back to an isometrically projected world

I am doing a behind the curtains 3d simulation while rendering the world in my 2d isometric engine. I've never done an isometric engine before, and my matrix math is rusty in general so I am having problems. I have a projection matrix, which in its simplest form is this: 0.7 0.35 0 0 -0.87 0 -0.71 0.35 1...

Possible ways to calculate X = A - inv(B) * Y * inv(B) and X = Y + A' * inv(B) * A

Hi, I have two problems. I have to calculate two equations: X = A - inv(B) * Y * inv(B) and X = Y + A' * inv(B) * A where, A, B and Y are known p*p matrices (p can be small or large, depends the situation). Matrices are quite dense, without any structure (except B being non-singular of course). Is it possible to solve X in those e...

Animating a MatrixTransform in WPF from code.

I have a Canvas which I would need to animate the RenderTransform property of. The start and end matrices will be abitrary, so I can't pre write the storyboard in XAML, so I'm trying to do it in code, I can't find any example of how to do this, below is my best try which does not work (it compiles and runs, but the rendertransform does ...

Is there Fortran subroutine in LAPACK/BLAS or somewhere else to calculate LDL decomposition?

Like the title says, I need to form cholesky LDL decomposition for my positive definite matrix A (Like normal cholesky, but there's ones one diagonal of L, and D is diagonal matrix). I have found only one function in Lapack which does that, but it says the matrix A has to be tridiagonal. Is there somekind of function which does that in s...

Creating lists of lists in a pythonic way

I'm using a list of lists to store a matrix in python. I tried to initialise a 2x3 Zero matrix as follows. mat=[[0]*2]*3 However, when I change the value of one of the items in the matrix, it changes the value of that entry in every row, since the id of each row in mat is the same. For example, after assigning mat[0][0]=1 mat is [[...

Which one is faster / more stable: inverting matrix or solving three systems of linear equations with multiple right hand sides?

Hi, I have two equations I'm solving on each recursive round: X = A - inv(B) * Y * inv(B), X = X + A' * inv(B) * A, I solve the problem this way: C = inv(B)Y <=> BC = Y, solve C. D = Cinv(B) <=> DB = C <=> B'D' = C', solve D' E = inv(B)*A <=> BE = A, solve E. All matrices change over time, so I have to do this (or inverting) again...

Hash function to matrix

I have two matrices and I need to compare them, but I don't want to compare position by position, I think that is not the best way. I thought of hash functions, does anyone know how to calculate the hash of a matrix? ...

How to test if matrix is diagonal?

I need to test if one variance matrix is diagonal. If not, I'll do Cholesky LDL decomposition. But I was wondering which would be most reliable and fastest way to test is matrix diagonal? I'm using Fortran. First thing that come to my mind is to take sum of all elements of matrix, and substract diagonal elements from that sum. If the an...

Comparing two matrices in Matlab

I have two matrices x and y, both are results from different algorithms/routines that are supposed to calculate the same result. While I know that the isequal() would check if x and y are the same matrix, the entries in those matrices would not be exactly the same (i.e. some entries may be with 5% off in worst case scenario). In this sce...

Using graph theory to generate an exam schedule

Hey SO, I came across this website while looking for help on the internet regarding adj. matrix / graph theory. My program layout is as follows: student name + courses stored in a 2D array array with all distinct courses I am trying to achieve the following: use adjacency matrix to create an exam schedule where no student needs ...

Statistics and matrix algebra in Ruby

I need to inverse a variance-covariance matrix in Ruby and vector by matrix multiplication. Which numerical Ruby library/Gem should I use? ...

OpenGL Rotation Matrices And ArcBall

I have been tasked with creating a OpenGL scene implementing ideas such as simple movement, and an Arcball interface. The problem I am having is dealing with the rotation matrix which NeHe's Arcball class (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48) computes. What I have so far is a very simple solar system (just the ear...

Simple 3x3 matrix inverse code (C++)

What's the easiest way to compute a 3x3 matrix inverse? I'm just looking for a short code snippet that'll do the trick for non-singular matrices, possibly using Cramer's rule. It doesn't need to be highly optimized. I'd prefer simplicity over speed. I'd rather not link in additional libraries. Primarily I was hoping to have this on Sta...

Efficient way to find "matches" in a matrix in java

I have an existing (java) application that models an order book, as it stands each order is visible to every other. There is now a requirement to put (what is effectively) a per order ACL in place. An example to illustrate, lets say I have access groups [V-Z] and orders [A-F] A B C D E F V 1 0 0 1 1 0 W 0 1 1 0 0 1 X ...

How can I create a triangular matrix based on a vector, in MATLAB?

Let's say I've got a vector like this one: A = [101:105] Which is really: [ 101, 102, 103, 104, 105 ] And I'd like to use only vector/matrix functions and operators to produces the matrix: 101 102 103 104 105 102 103 104 105 0 103 104 105 0 0 104 105 0 0 0 105 0 0 0 0 or the following matrix: 101 102 103 104 105 0 ...

BLAS subroutines dgemm, dgemv and ddot doesn't work with scalars?

Hi, I have a Fortran subroutine which uses BLAS' subroutines dgemm, dgemv and ddot, which calculate matrix * matrix, matrix * vector and vector * vector. I have m * m matrices and m * 1 vectors. In some cases m=1. It seems that those subroutines doesn't work well in those cases. They doesn't give errors, but there seems to be some numer...

Actionscript Translation transformation

Hi I am working on actionscript 3 which I have to use translation rotation scaling to a movieclip. I have the rotation and scaling working properly but when I dealing with translation I find the problem that the translation will move the object outside of the origin so when I wanted to rotate the object, the object no longer rotate as ex...