matrix

how do i fill the entries of this matrix in R?

Given: h_i=t_(i+1)-t_i for i=1,...,n-1 where n is a positive integer. The matrix Q is an n by (n-2) matrix with entries q_(i,j) with i=1,...,n and j=2,...n-1 given by: q_(j-1,j)=1/h_(j-1) q_(j,j)=-(1/h_(j-1)+1/h_j) q_(j+1,j)=1/h_j q_(i,j)=0 for |i-j|>=2 I want to get a matrix Q. How do i write a program for this matrix in R? Many t...

Matlab Problem: If i have a set of matrix and would like to compare any values in the matrix with a number then replace it with 1 or0.

Hi all, I am really new with matlab and would like some helps with matlab.. Here is the problem: Say if i have a 256 by 256 matrix. I would like to replace any values that are 'greater' or 'equal' to 10 with 'one' and name the rest as 'zero' i.e. (values <10).. How can I do it?? For example, 2 3 6 15 24 32 1 7 39 10.... 1 5 7 11 19...

Numpy matrix to array

I am using numpy. I have a matrix with 1 column and N rows and I want to get an array from with N elements. For example, if i have M = matrix([[1], [2], [3], [4]]), I want to get A = array([1,2,3,4]). To achieve it, I use A = np.array(M.T)[0]. Does anyone know a more elegant way to get the same result? Thanks! ...

Problem converting a Matrix to Data Frame in R (R thinks all numeric types are factors)

Hello! I am passing data from C# to R over a COM interface. When the data arrives in R it is housed in a 'Matrix'. Some of the functions that I use require that the data be inside a 'DataFrame' instead. I convert the data structure using newDataFrame <- as.data.frame(oldMatrix) The table of data reaches R just fine, once I make the...

library for matrices in c++

I have a lot of elements in a matrix and when I access them manually it takes a pretty long time to eliminate all the bugs arising from wrong indexing... Is there a suitable library that can keep track of e.g the neighbors,the numbering, if an element is in the outer edge or not and so on. e.g. VA= 11 12 13 14 21 22 23 24 31 32 33 34 4...

opengl matrix rotation quaternions

Im trying to do a simple rotation of a cube about the x and y axis: I want to always rotate the cube over the x axis by an amount x and rotate the cube over the yaxis by an amount y independent of the x axis rotation first i naively did : glRotatef(x,1,0,0); glRotatef(y,0,1,0); then but that first rotates over x then rotates over ...

c++ large matrix inversion methods

Hi I've been doing some research about matrix inversion (linear algebra) and I wanned to use c++ template programming for the algorithm , what i found out that there are number of methods like: Gauss-Jordan Elimination or LU Decomposition and I found the function LU_factorize (c++ boost library) I want to know if there were other metho...

Looking for an elegant and efficient C++ matrix library

Greetings, googling for that subject brings, e.g., MTL, exmat, LAPACK and also here. I also seem to remember that Microsoft Research released one, but can't put my hands on it. I look for advice from someone who actually used (or developed...) one of those, hoping to achieve a Matlab experience inside C++ (as much as possible). Thanks in...

using dispatchDraw(Canvas) to obtain subsection of video preview

The following is the overriden dispatchDraw in a subclass of SurfaceView. I'm trying to change the parameters of the Surface(getting only a subsection of the video preview. @Override public void dispatchDraw (Canvas canvas) { Log.d(TAG,"**************inside dispatchDraw************"); int VIEW_WIDTH = canvas.ge...

Iterating over the big matrix containing 3000 rows and calculate the correlation.

Hello, I am trying to loop over the a matrix and do the correlation coefficiency of each two-row and print out the correlation matrix. ID A B C D E F G H I Row01 0.08 0.47 0.94 0.33 0.08 0.93 0.72 0.51 0.55 Row02 0.37 0.87 0.72 0.96 0.20 0.55 0.35 0.73 0.44 Row03 0.19 0.71 0.52 0.73 0.03 0.18 0.13 0.13 0.30 Row04 0.08 0.77 0.89 0.12 0...

Efficient way to find explanations of a method-test-matrix (mathematical problem)

Setup: I have a boolean matrix e.g. 1 0 1 1 0 1 where rows are named m1, m2, m3 (as methods) and columns t1 and t2 (as tests). Definition: An explanation is a set of rows (methods) which in union have at least one "1" in any column (every test hast to be matched by at least one method). in our example, the set of explanations ...

Iterating over the big matrix containing 3000 rows and calculate the correlation.-Follow-up!

Thanks Nico! Almost got there after I corrected small bugs. Here I attache my script: datamatrix=read.table("ref.txt", sep="\t", header=T, row.names=1) correl <- NULL for (i in 1:nrow(datamatrix)) { correl <- apply(datamatrix, 1, function(x) {cor(t(datamatrix[, i]))}) write.table(correl, paste(row.names(datamatrix)[i], ".txt", sep...

How to get rotations from btTransform to D3DXMatrixRotationYawPitchRoll ?

I need to get rotation data from Bullets rigid body world transform ( getWorldTransform() ) to the suitable format to pass to D3DXMatrixRotationYawPitchRoll function to generate the rotation matrix for DirectX. My solutions structure is built up this way so I need to pass the data this way. You can provide other solutions, maybe I can s...

Android - Setting bitmap collision detection after rotation by matrix

How do I create code for collision detection on a bitmap rotated by a matrix? canvas.drawBitmap(mAnimation, mainMatrix, null); mainMatrix is derived from a PathMeasure so i do not know the rotation The bitmap is rotated around x=0,y=0 and thus a circle around the centre will not work (or at least be too big) thanks ...

Haskell doubt: how to transform a Matrix represented as: [String] to a Matrix Represented as [[Int]] ?

Im trying to solve Problem 11 of Project Euler in haskell. I almost did it, but right now im stuck, i want to transform a Matrix represented as [String] to a Matrix represented as [[Int]]. I "drawed" the matrices: What i want: "08 02 22 97 38 15 00 40 [ ["08","02","22","97","38","15","00","40"], [[08,02...

Building a 3x3 reflection matrix using GSL

Based on the documents http://www.gnu.org/software/gsl/manual/html_node/Householder-Transformations.html and http://en.wikipedia.org/wiki/Householder_transformation I figured the following code would successfully produce the matrix for reflection in the plane orthogonal to the unit vector normal_vector. gsl_matrix * reflection = gsl...

OpenGL-OpenTK rotation problems

Hi there! I'm a real noob who just started learning 3d programming and i have a really hard time learning about rotation in 3D space. My problem is that I can't seem to figure out how to rotate an object using it's local coordinates. I have a basic class for 3d objects and, for starters, i want to implement functions that will rotate th...

Compact Matrix in Latex

For a summary I want to display a latex matrix in an as compact as possible way. How can I do that? ...

Factoring matrices into elementary matrices

Is there a package in MATLAB, Maple or Mathematica which does this? ...

What command that will erase all but the first three columns of a matrix in matlab?

I am essentially trying to take a matrix a and turn it into a matrix af which has the values in the first three columns of a. I just want to prune a matrix a down to only its first three columns. ...