matrix

How can I find the index of the maximum value in a matrix column in MATLAB?

I'm trying to find the maximum value of a certain column in a matrix. I want to find both the maximum value and the index of the row in which it is. How can I do this? ...

If a world matrix and camera matrix are both identity matrices, can they be ommited?

This is a basic question about the need for world and camera space matrices when each are identity matrices. Can they be ommited when calculating a 2D projection? I'm pretty sure that they can, although I seem to be getting strange results when I try to project some 3D points whilst ommiting them, I ask since this might be directly linke...

How can I solve a system of linear equations in Excel

Hi, I am having some trouble finding a solution for a system of equations using excel. The system is of the form Ax=b, with A a matrix and x and b vectors. Obviously, the goal is to find x. The system does not necessarily have the same number of equations and unknowns. An exact solution is not always possible. Therefor I want to find t...

convert camera position

I have a function from an external lib which takes the following camera parameters: x,y,z coordinates for "center of orbit" x,y,z vector from "center of orbit" to "camera direction" orbital radius camera roll How can I calculate these parameters from the ones I got: position vector view vector zoom min/max rotation angle decline an...

Code not working for image processing in matlab

I wish to compute this formula in matlab [m,n,d]=size(img1); matrix1=sum(abs(img1-img2)); a= matrix1/ m*n ; b=a*100; where img1,img2 are two images of dimension 512*512*3 The objective is to obtain a single numeral value, but i am getting a matrix. The actaul formula in case of a matrix A,B with i rows and j columns is = (summation [...

Time Aware Social Graph DS/Queries

Classic social networks can be represented as a graph/matrix. With a graph/matrix one can easily compute shortest path between 2 participants reachability from A -> B general statistics (reciprocity, avg connectivity, etc) etc Is there an ideal data structure (or a modification to graph/matrix) that enables easy computation of the ...

Scipy sparse matrix question

Hi, I have the following code in Python using Numpy: p = np.diag(1.0 / np.array(x) How can I transform it to get the sparse matrix p2 with the same values as p without creating p first? Thanks! ...

Need help reading from a txt file in C

Hello, I am working on a project in C which requires me to read in matrix values from a txt file. The first two lines are the number of rows and columns, and the rest is the actual matrix data. For example, something like this: 2 2 1.0 2.0 3.0 4.0 The code I wrote is giving me some issues. Here's a snippet: matrix read(char* file...

How can I compute the picking ray with multiple model view matrixes?

I'd like to compute the intersection between a ray and the models the user sees on the screen of my app. I'm following the OpenGL guide but I have many models in the scene that I draw independently and dynamically in a push-pop context applying a translate to the current modelview matrix (ie for each model I do a glPushMatrix, glTrans...

reporting services matrix row question

I have a report that i'm trying to display in a matrix. The Row is grouped by a column called Category. The column name is vcName. The detail is vcTaskName. The part that i can't seem to figure out is that only one row will show up even if there are multipal tasknames with that row value. Try to give an example. Category vcTa...

Ruby core Matrix vs NArray's NMatrix

There seems to be two matrix modules in Ruby that I've found Matrix: Part of core Ruby it seems NMatrix: Part of the NArray library At the moment it seems NMatrix is faster, has some more helpful methods, but require a bit more setup. Is there anyone with experience of both who can give a rough overview of why I should use one over ...

Dijkstra on adjacency matrix in C

Hi all, I need some help with Dijkstra's algorithm in C. I've generated my adjacency matrix, that looks something like: int mat[NB][NB] = {{0, 171, MAX, 132, [...]}, {171, 0, 30, 39, [...]}, , [...]}; I've found this implementation: http://www.answers.com/topic/dijkstra-s-algorithm-1 but the path is an 1-dimensional array and my ma...

Interview Question: How to efficiently search in an ordered matrix?

I have a x by y matrix, where each row and each column are in ascending order as given below. 1 5 7 9 4 6 10 15 8 11 12 19 14 16 18 21 How to search this matrix for a number in O(x+y)? I was asked this question for an interview, but could not figure out the way. Curious to know if it could be done. ...

Clustering with a distance matrix

Hi, I have a (symmetric) matrix M that represents the distance between each pair of nodes. For example, A B C D E F G H I J K L A 0 20 20 20 40 60 60 60 100 120 120 120 B 20 0 20 20 60 80 80 80 120 140 140 140 C 20 20 0 20 60 80 80 80 120 140 140 140 D 20 20 20 0 60 80 80 8...

Programatically fill a nxn matrix with a gaussian filter in C++

I need to fill an nXn matrix with a Gaussian filter programatically. I've been trying to work this out for a graphics project, but i'm a little stuck. To clarify, an example 3x3 Gaussian filter matrix would be: [1, 2, 1] [2, 4, 2] / 16.0 [1, 2, 1] ...

Is there a Python equivalent of MATLAB's conv2 function?

Does Python or any of its modules have an equivalent of MATLAB's conv2 function? More specifically, I'm interested in something that does the same computation as conv2(A, B, 'same') in MATLAB. ...

I'm looking for a C library that is able to compute 4x4 and 3x3 matrix math.

Does anyone know a good one? I'm looking for multiplication of matrices, transpose, invert, converting from 4x4 to top left corner 3x3 etc. ...

matrix operations on large matrices on limited memory

I need to do some matrix operations on my computer. These matrices are large 1000000x1000000 and more, some operations requiring TB of memory. Obviously these cannot be directly loaded into memory and computed. What approaches can I use to solve these matrices on my computer? Assuming that the matrices cannot be reduced further using mat...

Optimization of variable multiplication

[This was initially on matrices, but I guess it applies to any variable generically] Say we have Var1 * Var2 * Var3 * Var4. One of them sporadically changes, which one of them is random. Is it possible to minimize multiplications? If I do In case Var1 changes: newVar1 * savedVar2Var3Var4 I noticed that then I need to recalculate ...

C++ matrix-vector multiplication

Hello! When working with 3d graphics, sample shaders USUALLY use the following operation for vector position transformation: result = mul(matrix, vector); This obviously means the same as: result = mul(vector, matrix_transposed); Also, just to mention, most linear algebra libraries prefer to only leave the vector * matrix multiplic...