Rotation around Z from a non-skew, affine orthogonal projection matrix

I can't seem to find an answer to what I thought should be a fairly straightforward problem. I'm trying to get the z-rotation of a matrix which represents the scale, transform and rotation of an orthogonal projection which always looks towards Z. Just the rotation around Z. I realise that there may not be a solution that covers 100% of uses (non-affine, skew, etc), but I just need one for this case. Purpose is to get something else working (just need to fudge this part together for now) in a

Summation of difference between matrix elements

I am in the process of building a function in MATLAB. As a part of it I have to calculate differences between elements in two matrices and sum them up. Let me explain considering two matrices, 1 2 3 4 5 6 13 14 15 16 17 18 and 7 8 9 10 11 12 19 20 21 22 23 24 The calculations in the first row - only four elements in both matrices are considered at once (zero indicates padding): (1-8)+(2-9)+(3-10)+(4-11): This replaces 1 in initial matrix. (2-9)+(3-10)+(4-11)+(5-12): This replaces

Populate matrix with ones according to certain function values

I would like to populate a 10x10 matrix with ones at certain positions. For example eye(10) yields a matrix with ones along the diagonal, corresponding to a 45 degree vector if you will. Is it possible to create ones along the cells of let's say a 40 degree vector? My take on this would be to define a function like f(x) = -tan(40 deg) * x + 10 and match it with a matrix filled with zeros, creating ones where the function has function values. I'm not sure how to go about it though so any help i

Very slow matrix transpose operation with CUBLAS

I'm trying to parallelize a matrix transpose operation using the CUBLAS library (with cublasSgeam function). The output data are correct, but It's taking on average 150 more time than my CPU version. Why? CPU code (For transposing a matrix of N = 5000 by M=140) // Starting the timer float *matrixT = (float *) malloc (N * M * sizeof(float)); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) matrixT[(j*N)+i] = matrix[(i*M)+j]; // matrix is obviously filled

Matrix Extrinsic parameters of camera - are they constant?

I am wondering how can the extrinsic parameters of a camera be constant? I know that the rotation matrix aligns the world coordinate system axises to the camera coordinate system, and the translation matrix/vector aligns the origo on top of each other. But how can the parameters be constant? Would it not somehow be required that I know the orientation of the camera in world space? I.e. by an accelerometer or something? I hope someone can help me wrap my head around this.

Inverse of Boolean matrix

I have a boolean matrix A and I want to find the inverse of it A' (boolean matrix) where A.A' = I , I is the identity matrix and (.) operation is the boolean product of matrices (boolean product of matrices is like the traditional product of matrices but with addition replaced with the operation OR and with multiplication replaced with the operation AND). Is there any simple way to calculate the inverse of boolean matrix?

Bi-variate polynomial (2-D Matrix) multiplication: Not much gains in performance when mexing using CPP compared to Matlab

I looked around the forum but could't find the answer to my specific problem. Objective To compute A(x,y)^N where N is large - say 500. I store A(x,y) in Matlab the form of matrix where A(x,y)=\sum A(i+1,j+1)* x^i * y^j. Critical point to note is that I can't compute the real values of the coefficients because the coefficients are huge. So at each step I just store log of the coefficients so that I will always store the exponents of the coefficients but not the actual values which is importan

Matrix Check if user has already sent data to server?

I'm developing an app which will send data to a server about exam results which have been taken by the user, what would be the best solution at the server side to check if the user has already sent it's results to the server. I was thinking of a matrix of user and exam rows and columns and was about to create this matrix with a database, what would you suggest me to do?

Drawing of 2D matrix/heatmap

I'm relatively new to three.js but I get everything up and running. I want to misuse three.js for a 2d visualization. Now my question: I want to draw matrices as big as possible in this form: Maybe I even need something more sophisticated in the cells of the matrix. However there are just too many choices how to design this in three.js. Should I use plain boxes, planes or sprites?Should I dig into the particle system? Is there some

Torch - Lua / Get max index from matrix

I am trying to code a neural net for domineering The input is a matrix of 8 x 8 x 3. I organised the matrix as following : The first depth is for the state of the game, the second depth is flipped board and the last depth is the player plane The output is 8 x 8 is the best game to play aka the move to learn (generated by Monte Carlo Tree Search) Then the network is a 8 x 8 tensor with the probability of being the best game to play, I need to get the index (x,y) of the max probability of the te

Matrix Show that cross product of a x b is perpendicular to b

How do I know the cross product of A x B is perpendicular to B. I'm little confused because there are 3 vectors instead of 2. A = (0, -2, 5) B = (2, 2, -5) C= ( 7, -4, -5) On R2 plane, (a x b) * b = 0 proves that a x b is perpendicular to b , but how do I find that on R3.

(Using Julia) How can I reduce my data matrix by averaging values from the same hour?

I am trying to reduce the size of my data and I cannot make it work. I have data points taken every minute over 1 month. I want to reduce this data to have one sample for every hour. The problem is: Some of my runs have "NA" value, so I delete these rows. There is not exactly 60 points for every hour - it varies. I have a 'Timestamp' column. I have used this to make a 'datehour' column which has the same value if the data set has the same date and hour. I want to average all the values with the

Broadcasting 1s of a 2D matrix to a 1-hot 3D matrix

Given the 2D matrix A, how can I broadcast it to create 3D matrix B? A = [[1 1 1 1 0];[0 0 0 0 1]] B = cat([[1 0 0 0 0];[0 0 0 0 0]], [[0 1 0 0 0];[0 0 0 0 0]], [[0 0 1 0 0];[0 0 0 0 0]], [[0 0 0 1 0];[0 0 0 0 0]], [[0 0 0 0 0];[0 0 0 0 1]], dims=3) I've tagged numpy-broadcasting for this question because while I'm using Julia 1.2.0, Julia broadcasting is modelled on NumPy broadcasting, so there may be a similar shared solution.

Matrix How to extract yaw pitch roll from glm::quat and glm::mat4

Is it possible to extract the yaw, pitch and roll information from the glm::mat4? (That is a world transformation matrix with the translation, rotation and scale already applied) Here is some code that I'm experimenting with: float yawDeg = 0; float pitchDeg = 20; float rollDeg = 80; glm::mat4 transform = glm::eulerAngleYXZ(glm::radians(yawDeg), glm::radians(pitchDeg), glm::radians(rollDeg)); glm::quat rotation(transform); // Is this a correct way? // glm::quat rotati

Cannot save a matrix in the GUI but I can save the same matrix to the same folder in the command window

When I copy the third line to the command window, the file with mOrg matrix is saved and is OK. When I execute it in the GUI-editor window, it is not saved and I do not receive an error message! The writePath is a long path: D:\DATA-MEDION\bros\autoDwn\stommeUp2Date\crommejan.m.txt.dbl stored in a variable with class char and size 1,52 which was the length of the name. With this code : writePath=strcat('D:\',name,'.mat'); save writePath mOrg % NOT Ok ` With this code: save 'D:\D

Matrix Possible ways to calculate X = A - inv(B) * Y * inv(B) and X = Y + A' * inv(B) * A

I have two problems. I have to calculate two equations: X = A - inv(B) * Y * inv(B) and X = Y + A' * inv(B) * A where, A, B and Y are known p*p matrices (p can be small or large, depends the situation). Matrices are quite dense, without any structure (except B being non-singular of course). Is it possible to solve X in those equations without inverting the matrix B? I have to calculate these equations n times, n being hundreds or thousands, and all the matrices change over time. Thank you

Matrix Is there Fortran subroutine in LAPACK/BLAS or somewhere else to calculate LDL decomposition?

Like the title says, I need to form cholesky LDL decomposition for my positive definite matrix A (Like normal cholesky, but there's ones one diagonal of L, and D is diagonal matrix). I have found only one function in Lapack which does that, but it says the matrix A has to be tridiagonal. Is there somekind of function which does that in some free subroutine libraries like lapack?

GLM matrix 4X4 (mat4) to array and back

I need to put a glm math library mat4 into a sqlite3 BLOB and back. What would be the most efficient approach? Serialize mat4 to bytes?, Turn mat4 to a float array? BLOB will not take a mat4 directly adding brute force conversion of mat4 to array of floats :) using namespace glm; mat4 fM; float fma[16]; vec4 t0 = fM[0]; vec4 t1 = fM[1]; vec4 t2 = fM[2]; vec4 t3 = fM[3]; fma[0] =

Rotation matrix multiplication error

I am developing a 3 x 3 x 3 Rubik Cube with Direct3D 9, User can rotate one layer of the Rubik Cube by click and drag the layer, the rotation looks like this the underlaying implementation of the rotation was calculate by matrix multiplication, each time when user drag left mouse, i will generate the rotation angle and the rotation axis, and calculate the rotation matrix with them, then multiply the rotation matrix with the unit cube's world matrix in current layer, code as below The world "C

Matrix Reading matrices into Mata

I have some large matrices I want to process in Mata, i.e., typical matrix operations such as inverting, multiplying, etc. These are Stata files with variable names in the first row. Some are quite large, >15 GB. So, the first problem is reading the data. I read something about setting up views, but my version of Stata does not show any help for st_view. The help for Mata talks about opening a file with fopen(), but it's pretty cryptic. I also read something about Mata adding changes to th

loop to generate iterative rows of a matrix in mathematica

I have a matrix FT= {{0, 0, 0}, {1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 2, 1}, {1, 2, 2}, {1, 2, 3}, {1, 3, 1}, {1, 3, 2}, {1, 3, 3}, {2, 1, 1}, {2, 1, 2}, {2, 1, 3}, {2, 2, 1}, {2, 2, 2}, {2, 2, 3}, {2, 3, 1}, {2, 3, 2}, {2, 3, 3}, {2, 4, 1}, {2, 4, 2}, {2, 4, 3}, {2, 5, 1}, {2, 5, 2}, {2, 5, 3}, {2, 6, 1}, {2, 6, 2}, {2, 6, 3}, {3, 1, 1}, {3, 1, 2}, {3, 1, 3}, {3, 2, 1}, {3, 2, 2}, {3, 2, 3}, {3, 3, 1}, {3, 3, 2}, {3, 3, 3}, {3, 4, 1}, {3, 4, 2}, {3, 4, 3}, {3, 5, 1}, {3, 5, 2

Matrix Octave - Creating a sequence of odd numbers between 1 and 10 separated by zeros

Without explicitly typing in the values, and using only a single line of code (no semicolons!), I am trying to write a code that creates the following series of numbers, and outputs it to screen: a= 1 0 3 0 5 0 7 0 9 0 Here's my best attempt to achieve this, a= [1:10].*[1 0 1 0 1 0 1 0 1 0] This produces and displays the right result, but I still need a shorter way since I am typing in the values of the second matrix ([1 0 1 0 1 0...]). Any ideas? Thanks.

Warnings inmatrix multiplication in vhdl

So, I started writing the code for a simple 4x4 matrix multiplication. The code is very crude at this point, something I will try to change by the end, but I just wanted to see if it works. It uses direct assignment to the 2-bit elements of the matrices from the 8-bit inputs. Similarly, the 4 outputs are created by concatenating the 4 elements of each row of the resulting matrix. Below you can see the code. The problem I have is that after I run the code, I get about 100 warnings of the type

Matrix error LWJGL

I made this little game engine but when I setup matrix in shader GLSL position got annulled by it and any image goes displayed... Here GLSL program: "#version 450 core\n" + "layout(location=0) in vec2 in_Position;\n" + "layout(location=0) uniform mat4 uni_Model;\n" + "void main() {\n" + " gl_Position = uni_Model * vec4(in_Position, 0.0f, 1.0f);\n" + "}"; Here's my matrix: Matrix4f matrix

Hidden Markov Model Emission Probability Covariance is an identity matrix?

When using an HMM, the emission probability per state should be set. If it is not set, the covariance would be an identity matrix. This is the default covariance in most HMM libraries that I used. What does it mean if the covariance of an emission probability is an identity matrix?

Matrix Unproject Webgl

So I am trying to create a 2d drawing program in WebGL and I can draw everything fine but I am having a lot of difficulty detecting the location of mouse clicks. I have a 4x4 projection matrix set up as follows: mat4.perspective(45, /, 0.1, 100.0, projectionMatrix); I then have a 4x4 view matrix which holds the camera position as follows: mat4.translate(viewMatrix, [camera.getX(), camera.getY(), camera.getZoom()]); I can get a 2d vector of the

Matrix equation not properly updating in time

As a simple example to illustrate my point, I am trying to solve the following equation f(t+1) = f(t) + f(t)*Tr (f^2) starting at t=0 where Tr is the trace of a matrix (sum of diagonal elements). Below I provide a basic code. My code compiles with no errors but is not updating the solution as I want. My expected result is also below which I calculated by hand (it's very easy to check by hand via matrix multiplication). In my sample code below I have two variables that store solution, g is

Matrix APL Poker Game Scoring

I have a problem in APL which involves getting values and scoring them like a poker game. So I used CHARS⍸CAR3 5 29 30 8 29 23 5 34 34 33 2 34 3 34 6 10 10 15 6 15 15 Which is an integer representation of characters in "deck" of cards I then used {⍺,⍴⍵}⌸(HAND3[1;]) That returns the frequency of each letters index, for example the letter S appears 2 times denoted by the 29 occurring in the second row. I can't figure out how to do this for each row of my matrix which is 3 s

Matrix 3D mesh generation: How to choose up-axis when extruding 2D shape along 3D curve?

I have a 2D shape (a circle) that I want to extrude along a 3D curve to create a 3D tube mesh. Currently the way I generate cross-sections along the curve (which form the basis of the resulting mesh) is to take every control point along the curve, create a 3D transform matrix for it, then multiply the 2D points of my circle by those curve-point matrices to determine their location in 3D space along the curve. To create the matrix (from 3 vectors), I use the tangent on the curve as the up vecto

Matrix Inv() versus '\' on JULIA

So I am working on coding a program that requires me to assign and invert a large matrix M of size 100 x 100 each time, in a loop that repeats roughly 1000 times. I was originally using the inv() function but since it is taking a lot of time, I want to optimize my program to make it run faster. Hence I wrote some dummy code as a test for what could be slowing things down: function test1() for i in (1:100)

Quotient in R to hold position in a matrix

Let's assume these are our numbers and we are looking for mod for them which we can find them using library(pracma) > mod(c(1,4,23,13,8,9,11,27,32,2),7) > [1] 1 4 2 6 1 2 4 6 4 2 I want to get a number to see where each number is coming from when it is a matrix? 1,1,4,2,2,2,2,4,5,1 For example; if this is an m by 7 matrix; We know that it is on 2nd column but what row? 9 is 2nd row (2,2) but not quotient is 1, then 23 is 4th row (4,2) but quotient is 3. Finally, last element 2 is

How label the complex eigenvalues of a matrix in ascending order of their imaginary part in Octave?

When the function eig(a) is used, Octave does not seem to order complex eigenvalues in any particular order (while for real eigenvalues, Octave stores the eigenvalues and their eigenvectors in ascending order). I need to order the complex eigenvalues (and also their respective eigenvectors) of a matrix in ascending order of their imaginary part. Is there any built in routine to do that? If not, how to implement this?

Power BI matrix with added columns

I want to create a matrix in Power BI with the latest keyword ranks, with also 2 custom columns with the latest SearchVolume and latest Landingpage. I have a table looking like this: Keyword|Searchvolume|Date|Rank|Landingpage And created a matrix with the last 4 weeks to look like this: Keyword|Week 1|Week 2|Week 3|Week 4 I want to add 2 columns with only the latest searchvolume and landingpage Keyword|Searchvolume|Week 1|Week 2|Week 3|Week 4|Landingpage I've tried searching how to add a colu

Use integer in Matrix

Language : JAVA i would to program operation about Matrix" to do LU Decomposition for calculate determinant and..." I would like to calculate the determinant of a matrix, knowing that I have a matrix of integers so to do the calculations, I have to pass by division! but I don't have the right to divide two integers. there will surely mistakes, how do I proceed? Thank you...

Explain to me this solved matrix normalization exercise?

We have a 1024*1024 matrix with 32 bit numbers that is going to be normalized. Suppose that the size of the page in the virtual memory is 4KB and we allocate 1 MB of main memory to save the matrix while we are working. Suppose that we need 10 ms to upload a page from the disc. a) Suppose that we work with the matrix one column at a time. How many page faults will be caused to traverse all the matrix elements, if they are saved in the virtual memory by column? The answer is 1024, but I don't un

How to solve this ILP/CP matrix puzzle

I'm studying about algorithms and recently found the interesting challenge. It will give us some row/column, and our mission is to fill table with integer 1~N which displays only once and their row and column sums are equal to given row/column. The challenge simple example: [ ] [ ] [ ] 13 [ ] [ ] [ ] 8 [ ] [ ] [ ] 24 14 14 17 answer: [2] [6] [5] 13 [3] [1] [4] 8 [9] [7] [8] 24 14 14 17 Thanks

Matrix Implementing a Least Squares Kernel classifier

I am trying to find the equation I would need to use in order to implement a Least Squares Kernel classifier for a dataset with N samples of feature length d. I have the kernel equation k(x_i, x_j) and I need the equation to pug it into to get the length-d vector used to classify future data. No matter where I look/google, Although there are dozens of powerpoints and pdfs that seem to give me almost what I'm looking for, I can't find a resource which can give me a straight answer. note: I am n

Matrix Multiplying matrices with MPI (segmentation fault)

I've recently started learning MPI and, as you may have guessed, I have already encountered an error I can't solve on my own! I want to write a program that will multiply two matrices. However I haven't got that far, in fact, I'm stuck on broadcasting the matrices in the first place. #define MASTER 0 if (rank == MASTER) { A = (double *) malloc(N * N * sizeof(double)); B = (double *) malloc(N * N * sizeof(double)); matFillRand(N, A); matFillRand(N, B); } if

How to shuffle a "DenseMatrix" in F#

In Matlab we can write the following code to shuffle a matrix: data = data(:, randperm(size(data,2))); there is what I write with Math.NET: let csvfile = @"../UFLDL-tutorial-F#/housing.csv" let housingAsLines = File.ReadAllLines(csvfile) |> (fun t -> t.Split(',') |> (fun t -> float t)) let housingAsMatrix= DenseMatrix.OfRowArrays housingAsLines let housingAsMatrixT = housingAsMatrix.Transpose() let v1 = DenseVector.Cre

Power BI - Matrix Drill-down Causes Upper Level in Hierarchy to Disappear

I am working with a client new to Power BI, and they complain that when drilling down to the next level, the level above "disappears" showing only the parent of the drill-down records, as shown here: Top Level Shows All Records After drill-down, we see the next level down, but only the parent record at the level above: Here, the lower drill-down records appear, but only their parent appears from the level above. My client would like the hierarchy to still display the parent levels while

How do I place user-inputted numbers into a matrix in TI-BASIC?

I am trying to take user-inputted numbers and put them into a matrix in my program code. I have tried about two dozen permutations of things, and I can't seem to define any number past Row 1, Column 1. Essentially I am trying to use the TI-BASIC equivalent of what would be x = A(r,c) in MATLAB. The :List>Matr({Lv},[B] line is where the program stops. I hope that I have made my question clear; I am happy to clarify any questions that you may have in assisting me. Thank you! Program Code

Matrix Polynomial Function Expansion in R

I am currently reviewing this question on SO and see that the OP stated that by adding more for loops you can expand the polynomials. How exactly would you do so? I am trying to expand to polyorder 5. Polynomial feature expansion in R Here is the code below: polyexp = function(df){ df.polyexp = df colnames = colnames(df) for (i in 1:ncol(df)){ for (j in i:ncol(df)){ colnames = c(colnames, paste0(names(df)[i],'.',names(df)[j])) df.polyexp = cbind(df.polyexp, df[,i]*df[,j]

Matrix Weird behavior with orthogonal procrustes

Given two matrices mat1 and mat2, each one representing a set of 3 points in a 3 dimensional space, I want to rotate mat2 so that it matches mat1 using orthogonal procrustes : mat1 <- t(matrix(c(1.16, 0.21, 0.11, -0.78, -0.02, -0.73, -0.37, -0.18, 0.62), nrow=3)) mat2 <- t(matrix(c(0.40, -0.94, -0.05, -0.91, 0.24, -0.38, 0.51, 0.70, 0.43), nrow=3)) Q <- cds::orthprocr(mat1 , mat2)$Q mat2_rotated <- mat2 %*% Q The matrix Q should then represent the optimal rotation / reflection to a

  1    2   3   4   5   6  ... 下一页 最后一页 共 10 页