matrix

Aligning matrix nodes in tikz

Another question about aligning nodes using matrices in tikz. Consider the following: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix (m)[matrix of nodes, column sep=5mm,row sep=3mm, align=center, nodes={rectangle,draw, text width = 2cm} ]{ & \node{row1-2...

Matlab matrix translation and rotation multiple times

I have a map of individual trees from a forest stored as x,y points in a matrix. I call it fixedPositions. It's cartesian and (0,0) is the origin. Given a velocity and a heading, i.e. .5 m/s and 60 degrees (2 o'clock equivalent on a watch), how do I rotate the x,y points, so that the new origin is centered at (.5cos(60),.5sin(60)) and...

Last Observation Carried Forward In a data frame?

Hi all, I wish to implement a "Last Observation Carried Forward" for a data set I am working on which has missing values at the end of it. Here is a simple code to do it (question after it): LOCF <- function(x) { # Last Observation Carried Forward (for a left to right series) LOCF <- max(which(!is.na(x))) # the location of the...

Create a basic matrix in C (input by user !)

Hi there, Im trying to ask the user to enter the number of columns and rows they want in a matrix, and then enter the values in the matrix...Im going to let them insert numbers one row at a time. How can I create such function ? #include<stdio.h> main(){ int mat[10][10],i,j; for(i=0;i<2;i++) for(j=0;j<2;j++){ scanf("%d",&mat[i][...

MATLAB: How do I get 3D coordiantes from a user-click?

I'm using Matlab to create a small chess game for one of my courses this semester. The thing I'm having trouble with is having the user be able to select one of the chess pieces. To simplify things, I'm making it so that the user selects a piece by clicking on the square that the chess piece resides on rather than clicking the piece it...

R: How can I reorder the rows of a matrix, data.frame or vector according to another one.

test1 <- as.matrix(c(1, 2, 3, 4, 5)) row.names(test1) <- c("a", "d", "c", "b", "e") test2 <- as.matrix(c(6, 7, 8, 9, 10)) row.names(test2) <- c("e", "d", "c", "b", "a") test1 [,1] a 1 d 2 c 3 b 4 e 5 test2 [,1] e 6 d 7 c 8 b 9 a 10 How can I reorder test2 so that the rows are in the same order a...

Java array of arry [matrix] of an integer partition with fixed term

Hello, for my study purpose I need to build an array of array filled with the partitions of an integer with fixed term. That is given an integer, suppose 10 and given the fixed number of terms, suppose 5 I need to populate an array like this 10 0 0 0 0 9 0 0 0 1 8 0 0 0 2 7 0 0 0 3 ............ 9 0 0 1 0 8 0 0 1 1 ............. 7 0 1 1...

Typesetting a large matrix in LaTeX

I have a 3x12 matrix I'd like to input into my LaTeX (with amsmath) document but LaTeX seems to choke when the matrix gets larger then 3x10: \begin{equation} \textbf{e} = \begin{bmatrix} 1&1&1&1&0&0&0&0&-1&-1&-1&-1\\ 1&-1&0&0&1&1&-1&-1&0&0&1&-1\\ 0&0&1&-1&1&-1&1&-1&1&-1&0&0 \end{bmatrix} \end{equation} The error: Extra alignment tab...

Matlab: How to create a 3D matrix?

Hi, Does anyone know how to define a 3D matrix in matlab, for example a matrix of size (8 x 4 x 20) or add a 3rd dimension to an existing 2D matrix? Thank you. ...

C++ template typedef

I have a class template<size_t N, size_t M> class Matrix { // .... }; I want to make a typedef which creates a Vector (column vector) which is equivalent to a Matrix with sizes N and 1. Something like that: typedef Matrix<N,1> Vector<N>; Which produces compile error. The following creates something similar, but not exactly what...

Fast 4x4 matrix multiplication in Java with NIO float buffers

I know there are LOT of questions like that but I can't find one specific to my situation. I have 4x4 matrices implemented as NIO float buffers (These matrices are used for OpenGL). Now I want to implement a multiply method which multiplies Matrix A with Matrix B and stores the result in Matrix C. So the code may look like this: class M...

How to extract a 2x2 submatrix from a bigger matrix

Hello, I am a very basic user and do not know much about commands used in C, so please bear with me...I cant use very complicated codes. I have some knowledge in the stdio.h and ctype.h library, but thats about it. I have a matrix in a txt file and I want to load the matrix based on my input of number of rows and columns For example, I...

OpenGL, problems with GL_MODELVIEW GL_PROJECTION...

Guys, I'm trying to finish up my homework but I'm having some problems here on these models on openGL... any Idea why is my draw not happening? One thing that strange is that if I change to gluPerspective it works.. #include <GL/glut.h> #include <stdlib.h> #include <stdio.h> static int shoulder = 0; static int elbow = 0; void init(voi...

Transposing a matrix

Hello, I want to transpose a matrix, its a very easy task but its not working with me : UPDATE I am transposing the first matrix and storing it in a second one The two arrays point to the same structure I need two arrays (target and source) so I can display them later for comparison. struct testing{ int colmat1; ...

One row is skipped each time the program scans a matrix from file !

Hello there, I had this code working yesterday, but it seems like I edited it a bit and lost the working version. I cant get this to work anymore. I basically want to scan a matrix from a .txt file. But each time it scans the first row, the second one is skipped, and it reads the third instead :( Here is my code : for(i=0;i<=test->ro...

java double[][] - display as image

Hi all, just wondering if there is a simple way in java to display the contents of say 16x16 array of doubles [0..1] as a greyscale image (ala matlab)? using an unfamiliar matrix library, so I'd like to check that I'm on the right track. don't really care if it is slow or ugly, or if it requires external library - it's just there for a ...

Best way to get the highest sum from a Matrix (using Java but algorithm is the issue here)

Sorry I dont know the correct terminology to use but I have a 3x3 matrix like this 1 3 4 5 4 5 2 2 5 and I want get the highest score by picking a value from each row/column but I cant pick the same row or column more than once , so the answer in this case is 3 + 5 + 5 = 13 (row0,col1 + row1,col0 + row2,col2) 4 + 5 + 5 = 14 is ...

Select all points in a matrix within 30m of another point

So if you look at my other posts, it's no surprise I'm building a robot that can collect data in a forest, and stick it on a map. We have algorithms that can detect tree centers and trunk diameters and can stick them on a cartesian XY plane. We're planning to use certain 'key' trees as natural landmarks for localizing the robot, using ...

Performing a SVD on tweets. Memory problem

EDIT: I the size of the wordlist is 10-20 times bigger than I wrote down. I simply forgot a zero. EDIT2: I will have a look into SVDLIBC and also see how to reduce a matrix to its dense version so that might help too. I have generated a huge csv file as an output from my pos tagging and stemming. It looks like this: word1, w...

Multithreaded Multiplication of Large Non-sparse, Non-square Matrices in C/C++

All, I'm looking for recommendations for C or C++ libraries (preferably open source) that use multi-threaded techniques to multiply large, non-square, (e.g. 65536xn in size where n < 65536) non-sparse matrices. Thanks. -&& ...