matrix

draw 3d faces as 2d

I have 3d mesh and I would like to draw each face a 2d shape. What I have in mind is this: for each face 1. access the face normal 2. get a rotation matrix from the normal vector 3. multiply each vertex to the rotation matrix to get the vertices in a '2d like ' plane 4. get 2 coordinates from the transformed vertices I don't know if th...

Summing all numbers in a matrix

I just need what to do to be simplified. But if you write the source code I still want to know how and what u did explained. Write a function that sums all the integers in a matrix of integers using the following header: const int SIZE = 4; double sumMatrix (const double m [] [SIZE] , int rowSize, int columnSize) ; Write a test pro...

Matrix power in R

Trying to compute the power of a matrix in R, I found that package expm implements the operator %^%. So x %^% k computes the k-th power of a matrix. > A<-matrix(c(1,3,0,2,8,4,1,1,1),nrow=3) > A %^% 5 [,1] [,2] [,3] [1,] 6469 18038 2929 [2,] 21837 60902 9889 [3,] 10440 29116 4729 but, to my surprise: > A [,1] [,2] [,3...

Construct adjacency matrix in MATLAB

Consider a set of points arranged on a grid of size N-by-M. I am trying to build the adjacency matrix such that neighboring points are connected. For example, in a 3x3 grid with a graph: 1-2-3 | | | 4-5-6 | | | 7-8-9 We should have the corresponding adjacency matrix: +---+------------------------------------------------------+ | |...

Rotate 2D Array by 45 degrees

Hi, how can i rotate 2d rectangular array of integers that has odd number of rows by 45 degrees so something like int[] myArray = new int[,] { {1, 0 ,1}, {0, 1 ,0}, {0, 0 ,0}, } into int[] rotatedArray = new int[,] { {0, 1 ,0}, {0, 1 ,1}, {0, 0 ,0}, } for any dimension (3x3, 5x5, 7x7, etc.) by this "f...

How to write a makefile for a C++ project which uses Eigen, the C++ template library for linear algebra?

Hi Guys, I'm making use of Eigen library which promises vectorization of matrix operations. I don't know how to use the files given in Eigen and write a makefile. The source files which make use of Eigen include files as listed below, these are not even header files (They are just some text files)- <Eigen/Core> <Eigen/Dense> <Eigen/Eige...

CUDA Basic Matrix Addition - Large Matrices

Hi all, I'm trying to add two 4800x9600 matrices, but am running into difficulties... It's a simple C=A+B operation... Here is the kernel: __global__ void matAdd_kernel(float* result,float* A,float* B,int size) { int x=blockIdx.x*blockDim.x+threadIdx.x; int y=blockIdx.y*blockDim.y+threadIdx.y; int idx=x*y+x; ...

Determinant of a complex matrix in R

Is there a way to calculate the determinant of a complex matrix? F4<-matrix(c(1,1,1,1,1,1i,-1,-1i,1,-1,1,-1,1,-1i,-1,1i),nrow=4) det(F4) Error in determinant.matrix(x, logarithm = TRUE, ...) : determinant not currently defined for complex matrices library(Matrix) determinant(Matrix(F4)) Error in Matrix(F4) : complex matrices not...

develop distance matrix using coordinates

hey, I have been given a problem, I basically have been given a piece of grid paper of arbitary size and have to develop a distance matrix using only the coordinates for each of the grid points on the page. I'm thinking the best approach would be something like the Floyd-Warshall or Djikstra algorithms for shortest path pair, but don'...

Help me to make a algorithm to determine the Rank of a Matrix

I want to make a program which will determine the Rank of a given Matrix in C# Console Application. But I cannot able to make the algorithm for that. Can you please help me make that algorithm? ...

Image blurring in C++. Problem with copy of matrix

I am inputting a matrix of black/white pixel values and then I am blurring the inside using an averaging technique. I have the program looping through properly but I need a constant copy of the original matrix for the for loops to use when stepping through. How can I do this? #include<iostream> using namespace std; /****blurImage*****...

Android: Resizing and scaling a part of the image

Given an image, I want to be able to scale only a part of that image. Say, I want to expand half of the image so that, that half takes up the whole space. How is this possible? Will ImageView fitXY work because I thought it'll work only for the whole original image. @Override public void onCreate(Bundle savedInstanceState) { super.onC...

What is the best way to implement table which stores sparse data in C#

Hi All, I have a DataTable which stores very sparse data, something like: P1 P2 P3 P4 P5 ... J1 1 1 J2 1 1 J3 1 . . . The number of rows and columns might reach over 10^8. How can I store this data in more efficient way? Thanks. ...

How to derive camera rotation from 2d point

I have a camera mounted on a tripod its motion is restricted to pan and tilt rotation. It is looking at dot that is at a known location directly in front of the camera. If the camera looks at the dot and gets the 2d coordinate of it, is it possible to deduce the camera's rotation so that I can overlay some 3d models properly aligned to...

Hudson multiconfiguration project - anyway to filter based on node environment?

I have a set of GUI automation tests that take a rather long time to run. I've been looking into a multi-configuration Hudson project to run subsections of the tests in parallel. I'd like to set up a filter that only runs one subset on each slave node, rather than each subset on each slave node. Is there any way to include the slave nod...

CUDA Add Rows of a Matrix

Hi, I'm trying to add the rows of a 4800x9600 matrix together, resulting in a matrix 1x9600. What I've done is split the 4800x9600 into 9,600 matrices of length 4800 each. I then perform a reduction on the 4800 elements. The trouble is, this is really slow... Anyone got any suggestions? Basically, I'm trying to implement MATLAB's su...

Search a sorted 2D matrix

M is a 2D matrix of integers (nXm) they are sorted in both row and column Write a function search(int s) that return the exact location of the number or Null. What would be the most efficient way to do so? ...

What's the best way to sort a two-dimensional matrix by values?

I have a two-dimensional array: function getMatrix(size) { var matrix = []; for (var i = 0; i < size; i++) { matrix[i] = new Array(size); } return matrix; }; It is filled with numeric values, so every existing matrix[i][j] is a Number. What is the best way to get a sequence of i and j pairs that will correspon...

Is the WPF Matrix3D.Rotate() function innacurate?

I'm currently trying to wrap my head around WPF, and I'm at the stage of converting between coordinate spaces with Matrix3D structures. After realising WPF has differences between Point3D and Vector3D (thats two hours I'll never get back...) I can get a translation matrix set up. I'm now trying to introduce a rotation matrix, but it see...

Most efficient way to calculate the exponential of each element of a matrix

I'm migrating from Matlab to C + GSL and I would like to know what's the most efficient way to calculate the matrix B for which: B[i][j] = exp(A[i][j]) where i in [0, Ny] and j in [0, Nx]. Notice that this is different from matrix exponential: B = exp(A) which can be accomplished with some unstable/unsupported code in GSL (linalg....