matrix

Producing 2D array from a 1D array in MATLAB

Does anyone know if there is a way to produce a 2D array from a 1D array, where the rows in the 2D are generated by repeating the corresponding elements in the 1D array. I.e.: 1D array 2D array |1| |1 1 1 1 1| |2| |2 2 2 2 2| |3| -> |3 3 3 3 3| |4| |4 4 4 4 4| |5| |5 5 5 5 5| ...

Python module matrix class that implements Modulo 2 arithmetic?

Hi, I'm looking for a pure Python module that implements a matrix class where the underlying matrix operations are computed in modulo 2 arithmetic as in (x+y)%2 I need to do a lot of basic matrix manipulations ( transpose, multiplication, etc. ). Any help appreciated. Thanks in advance ...

Bone behaves differently in 3D Studio Max to DirectX or something else?

I have a rigged (biped) and animated model in 3D Studio Max which I've exported as a .x file. When I use it the animations run fine, however I've been trying to get the model itself to lean and turn from the hip but I'm having difficulty in finding where in the bone hierarchy I should apply the rotation matrices. In 3D Studio Max there...

dynamical two dimension array according to input

Hi, I need to get an input N from the user and generate a N*N matrix. How can I declare the matrix? Generally, the size of the array and matrix should be fixed at the declaration, right? What about vector<vector<int>> ? I never use this before so I need suggestion from veteran. ...

Should I always normalise a point after a homogenous transformation?

I'm just starting out with 3D math/programming and I have a question about point normalization: When doing transformations such as rotations, scaling, camera and perspective projections should I always normalize points so that w is 1 between transformations, or is it better to leave it until I'm ready to display them? Is there any reaso...

How does a convolution matrix work?

I know this isn't very relevant to programming, but I need to know how a convolution matrix works for a PHP GD function. I've searched a lot on Google, but can't find anything that explains it well. ...

Remove Translation from Matrix

Is it possible to remove just the translation element from a Matrix object so that only Scale and Rotation elements remain? Thanks ...

Best C++ Matrix Library for sparse unitary matrices

Hello, I am looking for a good (in the best case actively maintained) C++ matrix library. Thereby it should be templated, because I want to use a complex of rationals as numerical type. The matrices what I am dealing with are mainly sparse and unitary. Can you please suggest libraries and also give a small explaination why to use them, ...

Design pattern for ongoing survey anayisis

I'm doing an ongoing survey, every quarter. We get people to sign up (where they give extensive demographic info). Then we get them to answer six short questions with 5 possible values much worse, worse, same, better, much better. Of course over time we will not get the same participants,, some will drop out and some new ones will si...

XNA tearing when doing 2D camera transformations

I'm not sure why this is happening. Basically I render my tile map to the screen using a Spritebatch with a matrix transformation, and I get this weird tearing thing happening. Tearing Note that everything looks fine when I render using Matrix.Identity. This is the code that I use to create the Matrix: #region Creating Transfor...

How do I label two vectors in Matlab?

I have a 2 column matrix(called M, which I visualize as two vectors using Matlab's plot command(plot(M)). I have two issues: I want to label the vectors themselves on the plot. I want to label each row of the matrix(i.e. each vector component) on the plot. How would I go about doing those things? ...

Dynamic table / matrix data structure for Java

I need a Java implementation of table-like data structure where I could dynamically insert or delete rows and columns. I need to get data from any row or column very fast and with no overhead in selecting row over column or vice versa. Does anyone know libraries where such data structure is already implemented? ...

Associative Matrices?

I'm working on a project where I need to store a matrix of numbers indexed by two string keys. The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows. Similarly, if a row key exists for any column then it should exist for all columns. The obvious way to express this is with an associative a...

How can I solve a system of linear equations in Excel?

I have a system of 22 linear equations (exactly 22 equations and 22 unknowns) which are dynamically generated in an Excel spreadsheet. Is there a way to have Excel solve the system and produce a value for each of the unknown variables? Another SO question has a lot of good information about the algorithms used to solve such equations. C...

Reshape 3d matrix to 2d matrix

I have a 3d matrix (n-by-m-by-t) in MATLAB representing n-by-m measurements in a grid over a period of time. I would like to have a 2d matrix, where the spatial information is gone and only n*m measurements over time t are left (ie: n*m-by-t) How can I do this? ...

Comparing adjacent elements in MATLAB

Does anyone know how I can compare the elements in an array with the adjacent elements? For example, if I have an array: 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 Is there a way to cycle through each element and perform a logical test of whether the elements around it are equal ...

How to get gluLookAt parameters out of a 4x4 matrix

Sorry in advance if this is a really basic Matrix/OpenGl question. I have a situation where I have a 4x4 matrix that I would like to translate to, but don't want to use glMultMatrixf. I would rather use a gluLookAt method I've been using for most other translations. Is getting the values needed from the 4x4 matrix as simple as just pulli...

Algorithm for finding all cycles in a directed graph on C++ using Adjacency matrix

Given graph adjacency matrix (for ex. g[][]), graph is directed. Needs find count of all graph cycles (if exists) and print them. I tried to wrote this algorithm in Java, sometimes it works correctly. If graph has complex cycles, algorithm return crazy cycles. Please, look at my code and help to resolve this problem public static final...

Calculate the sum of elements in a matrix efficiently

In an interview I was asked if I was given an n*m matrix how to calculate the sum of the values in a given sub-matrix (defined by top-left, bottom-right coordinates). I was told I could pre-process the matrix. I was told the matrix could be massive and so could the sub-matrix so the algo had to be efficient. I stumbled a bit and was...

Is there a matrix math library that is good to use alongside OpenGL to keep track of primitive co-ordinates for collision detection

Matrix math library that is good to use alongside OpenGL to keep track of primitive co-ordinates. Does such a thing exist? Is this the best way to track my objects for use in collision detection? ...