matrix

How to find smaller matrices in a bigger matrix

I have a matrix say: Q = [05 11 12 16 25; 17 18 02 07 10; 04 23 20 03 01; 24 21 19 14 09; 06 22 08 13 15] I would like to list out all the possible 3x3 matrices. Some examples are: 11 12 16; 18 2 7; 23 20 3 and 5 11 12; 17 18 2; 4 23 20; etc.. Basically all the possible 3-by-3 matrices. How do I do it? ...

How to Compare 2 very large matrices using Python

I have an interesting problem. I have a very large (larger than 300MB, more than 10,000,000 lines/rows in the file) CSV file with time series data points inside. Every month I get a new CSV file that is almost the same as the previous file, except for a few new lines have been added and/or removed and perhaps a couple of lines have been...

boost compressed matrix basics

I am confused on how the boost::compressed_matrix works. Suppose I declare the compressed_matrix like this: boost::numeric::ublas::compressed_matrix<double> T(1000, 1000, 3*1000); This allocates space for 3*1000 elements in a 1000x1000 matrix. Now how do I give it the locations which are the non-zero elements? When and how are the non...

OpenGL and XNA Matrix differences

XNA has the following Matrix objects under BasicEffect public Matrix World public Matrix View public Matrix Projection OpenGL uses the following defines for glMatrixMode() GL_MODELVIEW GL_PROJECTION I'm not really sure why one would have more than the other, to be honest. I'm porting a GL game over, and it would be nice if I could...

WPF 3D: How to convert a single AxisAngleRotation3D into separate AxisAngleRotation3D?

I have a 3D viewport that uses the TrackBall of WPF 3D tool to rotate the object by mouse. As a result, I get a single AxisAngleRotation3D with Axis vector like (0.5, 0.2, 0.6) and Angle of e.g. 35. That's fine. What I would like to do is, as an alternative, to give user the ability to rotate the object by individual axis (i.e. x, y, z)...

SSRS matrix pivot

I have following structure: Col1 Col2 Col3 --------------- F P R1 F P R2 F P R3 F P R4 Col3 values can be anything. Now I want, in following format, only the top 3: Col1 Col2 Res1 Res2 Res3 ------------------------------ F P R1 R2 R3 I tried it using Matrix, but I m not able to separate t...

Python function to solve Ax = b by back substitution.

Okay, for my numerical methods class I have the following question: Write a Python function to solve Ax = b by back substitution, where A is an upper triangular nonsingular matrix. MATLAB code for this is on page 190 which you can use as a pseudocode guide if you wish. The function should take as input A and b and return x. Your functio...

Creating a matrix for a billboarded quad?

I'm trying to come up with a proper algorithm to create a matrix which gets the quad to face the camer straight up but I'm having difficulty. The quad I'm drawing is facing downwards, here's the code I have so far: D3DXVECTOR3 pos; pos = D3DXVECTOR3(-2.0f, 6.0f, 0.1f); D3DXMATRIX transform; D3DXMatrixTranslation(&transform, pos.x, pos....

Graph to compare two matrices in R

I have two matrices (of approximately 300 x 100) and I would like to plot a graph to see the parts of the first one that are higher than those of the second. I can do, for instance: # Calculate the matrices and put them into m1 and m2 # Note that the values are between -1 and 1 par(mfrow=c(1,3)) image(m1, zlim=c(-1,1)) image(m2, zlim=c...

Need help with Direct 3D's LookAt function ..

I need some conceptual help with Direct3D's .... function. In their official documentation, they say that the computation that takes place can be summarized with this: zaxis = normal(At - Eye) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) xaxis.x yaxis.x zaxis.x 0 xaxis.y yaxis.y ...

unable to determine cause of "no match for 'operator<'" compilation error

I am using CodeSourcery's implementation of the vector signal image processing library (vsipl++). I have written a function that is supposed to return [I + a*A]^-1 B, where I is the identity matrix, and A and B are compatible square matrices, as follows: namespace vsipl { template< class T1, class T2, class O1, class O2, class L1, cla...

How to use a matrix to rotate the reference system of a vector relatively to another?

Real-life case (helps understand the question) I am building a device that can freely rotate around all its axis (x, y, z) and is equipped with: an accelerometer (A) that gives me a vector pointing to the centre of the Earth (Va) a 3D magnetometer (M) that gives me the direction of the magnetic field of the Earth (Vm) The two vector...

Heading the right way on c matrix code?

My instructor said the way to start this is to use the getline() function from out book, then get the numbers from the line, then have those numbers in matrix form, I do not understand why I would use getline? //eventually this code should take in a square matrix and from 2x2 to 6x6 //the plan is to get it to read in a line, then get t...

numpy matrix multiplication

I am trying to figure out how to do a kind of scalar matrix multiplication in numpy. I have a = array(((1,2,3),(4,5,6))) b = array((11,12)) and i want to do a op b to result in array(((1*11,2*11,3*11),(4*12,5*12,6*12)) right now I am using the following expression c= a * array((b, b, b)).transpose() It seems like there must...

3D rotation with Axis & Angle

I know 3D rotation is well documented on SO and many other sites, but despite reading countless explanations I still haven't figured out where I'm going wrong. My background is in art and design, not math and programming, and I'm never really certain if my angle of attack (no pun intended) is the right one. Rather than paste a patchwork ...

I'm looking for specific matrices to plug into a convolution matrix

Assuming I already have a working convolution matrix algorithm in place, I'm looking for practical examples of general matrices that are useful for image processing in particular. The canonical examples you'll find everywhere are non-gaussian box blur: 1 1 1 1 1 1 1 1 1 Image sharpening: 0 -1 0 -1 5 -1 0 -1 0 Edge detec...

drawing lines in 3D (DirectX)?

I'm adding lines to my 3D world like we see in 3D studio max. To draw lines I'm using a cylinder mesh and simply stretching/rotating it appropriately. That's all working fine but my problem is scale. Since it's 3D geometry rendering in perspective its size changes, from a distance it's small to invisible, up close it's huge. I want to m...

Code to solve determinant using Python without using scipy.linalg.det

Description(this is a hwk question): I am not sure where to start here. I plan to use Laplace's Expansion but I am not sure how to implement it for nxn matrices. Any help would be appreciated. Note: I already have a function to generate random matrices for a nxn matrix. Also the timing the calculation isn't a problem. The only thing I...

How to convert a matrix to a 1 dimensional array in R

Hi I have a matrix file that is 32X48 and I want to put all of the values into a single dimensional array in R. Right now I am only able to get the last row of data. trgtFN_intensity <- "1074_B09_1- 4_5mM_Xgal_7d_W.cropped.resized.grey.png.red.median.colony.txt"; read.table(trgtFN_intensity, sep="\t") -> tmp_int maxrow_int <- nrow(...

Float and double precision in c#

Hi all, Having a bit of a problem here on a matrix multiplication code. I seem to lose precision on large matrices multiplications (my code runs fine on small matrices). My loop is the following : for (int j = 0; j < columns; j++) { float[] column = otherMatrix.Column(j); for (int i = 0; i < rows; i++) { double s =...