allocate matrix in C
hey, i want to allocate a matrix. is this the only option: int** mat = (int**)malloc(rows * sizeof(int*)) for (int index=0;index<row;++index) { mat[index] = (int*)malloc(col * sizeof(int)); } thanks ...
hey, i want to allocate a matrix. is this the only option: int** mat = (int**)malloc(rows * sizeof(int*)) for (int index=0;index<row;++index) { mat[index] = (int*)malloc(col * sizeof(int)); } thanks ...
I want to compute magnetic fields of some conductors using the biot-savart-law and I want to use a 1000x1000x1000 matrix. Before I use Matlab, but now I want to use Python. Is Python slower than Matlab? How can I make Python faster? EDIT: Maybe the best way is to compute the big array with c/c++ and then transfering them to python. I w...
I have a matrix that I want to randomize a couple of thousand times, while keeping the row and column totals the same: 1 2 3 A 0 0 1 B 1 1 0 C 1 0 0 An example of a valid random matrix would be: 1 2 3 A 1 0 0 B 1 1 0 C 0 0 1 My actual matrix is a lot bigger (about 600x600 items), so I really nee...
Assume you have a flat plane, with a bicycle resting on it. As the bicycle enters a turn, it leans into the turn with angle theta. At the same time, the bike frame points in the same direction as the bike velocity. Thus, given the bike velocity vector v (assumed to be in the XZ plane) and the lean angle theta, how can you find the rot...
Is MPI implementation of matrix inversion a standard library routine or good MPI implementation critically depends on your setup(software/hardware) so have to be coded by yourself. ...
I'm using a block processing approach to handle a calculation between two large matrices. The code significantly speeds up when using a larger block size. But if I go too large, then I get an Out of Memory error. Currently I hand-tune my code to find the largest working block size for a given input. My question: how can I automate ...
Hi! I've been having a very tiresome time when using flash10's Matrix3D class for 2D non-affine transformations. Basically, I have a square in a sprite and four points that form a quadrilateral, and I want to apply a transformation to the sprite to make those points the vertices of the sprite. There wouldn't be much problem solving thi...
Hi - I have a container with masked bitmap in it. The scale and rotation of this container changes at runtime, and I need to draw the masked bitmap but cannot figure out the appropriate matrix calculations to do so. My code works correctly to reflect position, scale, offset for centering without rotation. When rotated, the angle is cor...
Hii, The problem statement is: Buttons Each cell of an N x N grid is either a 0 or a 1. You are given two such N x N grids, the initial grid and the final grid. There is a button against each row and each column of the initial N x N grid. Pressing a row-button toggles the values of all the cells in that row, and pressing a column-butto...
Hi! with glMatrixMode(GL_TEXTURE); ..some matrix operations... i can change the current texture transformation matrix. However - it seems it affects not all texture units (i'm using multitexturing) how can i change the texture matrix for different texture units? thanks! ...
Hey, I'm writing an app for android (although I think this is a generic question) and I need to display a large image (in an ImageView) that can be scrolled and zoomed. I've managed to get scrolling to work by capturing touch events and performing matrix translations, and i'm now working on zooming. If I simply apply a scale transformat...
Is there any handy library can handle masking operation in Java? Taking care of element by element multiplication, masking boundary elements, etc. Thanks! ...
I know you can create easily nested lists in python like this: [[1,2],[3,4]] But how to create a 3x3x3 matrix of zeroes? [[[0] * 3 for i in range(0, 3)] for j in range (0,3)] or [[[0]*3]*3]*3 Doesn't seem right. There is no way to create it just passing a list of dimensions to a method? Ex: CreateArray([3,3,3]) ...
Hello, Maybe a very easy question, but I am already looking for hours on the Internet for the answer but I cannot find it. I have created the function below. In another m-file I want to use the matrix 'actual_location'. However, it is not possible to use an individual cell of the matrix (i.e. actual_location(3,45) or actual_location(1,2...
I need to compute the nullspace of several thousand small matrices (8x9, not 4x3 as I wrote previously) in parallel (CUDA). All references point to SVD but the algorithm in numerical recipes seems very expensive, and gives me lots of things other than the null space that I don't really need. Is Gaussian elimination really not an option...
hi I have a question about haskell coding. Matrices One of many ways to define matrices in Haskell is the list of matrix rows, where a row is a list of double precision oating point numbers: type Matrix=[[Double]] Using this type you should define the following functions (definition of dim is given as an inspirational example). dim...
Hello everyone! I have to make a control in ASP.NET that allows me to create a matrix. I have a list of strings (obtained from a method) that will be the rows (each string is one row), and I have another list of strings (obtained from other method) that will be the columns (each string is one column). After that, depending on the row-cl...
Hi. I was looking through the web for a way to dynamically allocate space for 3d matrix, say of int type. And i found many sites concerning 2d matrices, and this one http://www.taranets.com/cgi/ts/1.37/ts.ws.pl?w=329;b=286 And there was this example as shown down. I understood all of above examples but this concerning 3d i cannot. Is ...
Hello, I am not sure there are any R users out there, but just in case: I am a novice at R and was kindly "handed down" the following R code snippet: Beta <- exp(as.matrix(read.table('beta.transpose'))) WordFreq <- read.table('freq-matrix') WordProbs <- WordFreq$V1 / sum(WordFreq) infile <- file('freq-matrix') outfile <- file('doc_to...
I have two big arrays with about 1000 rows and 1000 columns. I need to compare each element of these arrays and store 1 in another array if the corresponding elements are equal. I can do this with for loops but that takes a long time. How can I do this faster? ...