41,259 questions
-1
votes
0
answers
32
views
Why is my 3D object texture rendering distorted? [closed]
So i am trying to make a 3D rendering engine with pure JS so i can learn the basics of computer graphics and computer rendering. Since i am trying do make it from scratch i am not using no libraries ...
1
vote
1
answer
59
views
Iterative solvers with right-preconditioning: inconsistency between applying the preconditioner to the matrix, or to x
Summary
Using the Eigen library, I see significantly different numbers of BiCGStab iterations when I solve Ax = b with a right-preconditioner, i.e., [A M^(-1)] Mx = b, (a) by precomputing A M^(-1) ...
1
vote
1
answer
112
views
Canvas Transform and Paint in Flutter
I want to achieve a transformation on the canvas using two fingers for rotation, scaling, and translation, while using one finger to paint in the correct position.
What I have so far:
import 'package:...
0
votes
1
answer
45
views
Using a colour matrix to isolate only yellow out of a grayscale
I do apologise if this is an incredibly dumb question, because I know it is,
I have no experience with colour matrices and the information I can find online to learn about them is unhelpful at best ...
1
vote
1
answer
58
views
What is the correct NumPy representation of a row vector for gradients
I am doing an assignment on matrices and gradients, where the final answer must be expressed as a row vector.
vr = np.array([1, 2, 3])
vrr = np.array([[1, 2, 3]])
Mathematically, a row vector should ...
3
votes
0
answers
103
views
How can I plot diagonals of matrix?
I want to plot all the diagonals of a matrix. In the matrix row 1 contains information of time 1, row 2 of time 2 etc etc. Each diagonal presents the evolution of the number of fishes in a cohort that ...
2
votes
2
answers
139
views
Applying a function to two matrices column-by-column
Short version: How do I vectorize two matrices A and B by column so that I can pass the 1st, 2nd, ..., ith column of A and the 1st, 2nd, ..., ith column of B to a function without a loop?
I have two ...
0
votes
1
answer
168
views
Why do my loops not start? Indexing loops problems?
I'm trying to convert a SAS program into a R one and I have stumbled at the for() loop and array part. It keeps saying in the log:
"Error in for (. in i) seq_len(NBR_LIGNES_MAX) : 4 arguments ...
2
votes
0
answers
88
views
How to properly allocate dynamic memory for matrix operations in C [duplicate]
I am trying to learn C, and I want to specifically work with arrays and matrices as I do scientific simulations (coming from python!!). After writing few basic 1-D array codes in C, I am going for ...
1
vote
2
answers
182
views
2D matrix convolution with convolve() in R
I am trying to perform 2D matrix processing (convolution) by applying a kernel/filter to a large matrix. There is a built-in function convolve that can perform convolution. It offers three different ...
0
votes
1
answer
67
views
How do jspdf transformation matrices work?
I am using transformation matrices with jspdf to change the origin and scaling of my drawings. setCurrentTransformationMatrix has no official documentation from what I found (well, except if "...
3
votes
7
answers
253
views
Using spreadsheet to make a pairwise comparison matrix
I want to use a spreadsheet to take a column of rankings and turning into a pairwise matrix. Suppose I had a column like so:
Candidate
Ranking
A
1
B
5
C
3
D
2
E
4
I want to create a 5x5 matrix where ...
2
votes
1
answer
200
views
How to filter and sum elements of a matrix in MATLAB based on multiple conditions without a loop?
I have the following numeric matrix in MATLAB:
A = [3 2 7; 9 1 4; 5 6 8];
I want to sum all elements that are greater than 5 and are also even.
I need to do this without using a loop, and store the ...
3
votes
6
answers
266
views
Is there an R function for placing a vector in the off-diagonal elements of a matrix?
I want to take a vector of some length and arrange it sequentially as the off-diagonal elements of a square matrix (as I want the diagonals to all be 0), using only the default R packages.
I can make ...
1
vote
1
answer
148
views
Why isn't my Hermitian covariance matrix invertible?
I am following a paper that uses a Hermitian covariance matrix
and inverts it to produce a Fisher matrix. I construct my covariance as Gamma[i,m,n], stored inside a larger array of shape (n_z, n_k, ...
2
votes
2
answers
168
views
How to detect singularity of a matrix before inverting it?
I have an algorithm which involves generating a random square matrix and then inverting it. To avoid the program interrupted by numerically singular matrix, I wish to do something like the pseudo-code ...
8
votes
3
answers
1k
views
How can I create an array of arrays of strings of varying lengths in C?
I am trying to solve the problem posed in this question. Here the OP asks that given a 15 element set, its 2^15 element power set be generated in a manner such that the elements of the power set are ...
1
vote
0
answers
106
views
Rewriting a n-dimensional matrix of dot products as a matrix multiplication
This is a crosspost from the Math Exchange forum, it seems to me that this question can be approached in two different ways so I am curious about different approaches.
https://math.stackexchange.com/...
1
vote
1
answer
95
views
Why doesn't Symbolics.expand work in matrices?
I'm working with Julia's Symbolics.jl and I'm trying to compare two symbolic matrices.
However, since Symbolics.isequal function checks for structural- instead of mathematical-equivalence it is ...
2
votes
1
answer
75
views
Why is Matrix Multiplication Slow During Pseudoinverse Calculation?
X, Z, YT = sp.linalg.svds(W, k=353, which='LM')
U = YT.transpose() @ np.diag(Z) @ X.transpose()
Where W is a sparse CSR matrix of size (124956, 124956). The matrix multiplication to compute U takes a ...
2
votes
0
answers
52
views
Transforming WebGL2 canvas based on touch events?
I want a webgl canvas that I can seemlessly translate, rotate and scale with multitouch (using touch events).
So far I have a canvas that I can translate with 1 finger or scale with 2 fingers, but I'm ...
2
votes
1
answer
240
views
How optimize my matrix transpose to be more cache-friendly in C?
I am working on my computer organization lab and trying to figure out how to make my matrix transpose more efficient for 64 by 64 integer array. For a cache configuration with 32 direct mapped sets ...
1
vote
0
answers
79
views
Givens Rotation on Python
I’m replicating Shapiro & Watson (1988) and need to impose the long-run restriction with a Givens rotation.
The target identity is
C_inf@B=C_inf(P@Q_total)=(C_inf@P)@Q_total=A@Q_total
Yet my code ...
1
vote
2
answers
70
views
PDF-Matrix operation shifting the coordinate system
Can someone explain me a special PDF matrix transformation? I just can't figure it out.
I have the following content stream of a PDF:
q
q
1.0000 0.0000 0.0000 1.0000 0.0000 0.0000 cm
q
1 0 0 -1 0 841....
0
votes
1
answer
44
views
Parallel sliding window computations with fixed intervals?
Sharing a common DolphinDB use case and solution for data processing.
How to implement a script in DolphinDB to perform sliding window calculations on a vector at equal intervals?
For example, ...
4
votes
3
answers
98
views
Combining matrices (above and below diagonal)
Say I have this matrices:
emp <- matrix(nrow = 13, ncol = 13)
emp2 <- matrix(nrow = 13, ncol = 13)
emp[lower.tri(emp)] <- 2
emp2[lower.tri(emp)] <- 3
And I want to combine them so below ...
-2
votes
1
answer
94
views
The recycling rule: proceeding from experience [closed]
The "Introduction to R" chapter 5.4.1 states:
The precise rule affecting element by element mixed calculations with vectors and arrays is somewhat quirky and hard to find in the references. ...
3
votes
1
answer
88
views
"Learning" R for Python translation
I'm a total beginner in "R". I'm doing a science research work, and I need to translate a R code (package) into Python (or C++, or whatever). I need help to understand what the matrix ...
0
votes
0
answers
66
views
MatLab Large File Mapping
I have large files (38 GB minimum) that contain data matrices of size (nRows, nCols, nFrames). I want to open and evaluate portions of these files. I'm interested in the most efficient way to do this.
...
2
votes
0
answers
133
views
How do I get the backtracking technique to solve large mazes too?
I'm developing a backtracking function to solve a maze given by a matrix of 0 and 1. The problem is that, for small matrices, it correctly finds the shortest path, but for matrices 15x15 or larger, it ...
0
votes
1
answer
113
views
DirectX. Quaternion to left-handed 3x3 matrix
I am using X-files to store 3D models. I want to take rotation from X-file. In X-file rotation is represented by quaternion. I am using DirectX 11 and left-handed coordinate system. I want to create ...
3
votes
2
answers
187
views
How can I calculate the number of local maxima in a 3D matrix in R?
I am currently working on a number of animal teeth stored as surface meshes in R. Some of the variables I am looking at may be influenced by the number of cusps on the tooth and I would like to try ...
1
vote
1
answer
244
views
Hot to get subtotal only for one column in Power BI Matrix
I am creating a matrix with three categorical columns: Group1, Group2 and Group 3, and one numeric column.
What I need is to turn off the subtotals for columns Group 2 & Group 3, and only keep the ...
0
votes
1
answer
101
views
Create a two-way table in R base that displays concatenated game results between players
Objective
To create a function in R {base} that produces a square matrix showing concatenated game results between players. The matrix should display the result of each pairwise match, concatenating ...
2
votes
1
answer
63
views
How should I take a matrix from input?
As we know input makes the inputs to string. How can I take matrix like this ([[1,2],[3,4]]) from input() by user and have it like a normal 2D list to do some thing on it.
It should be like that
data =...
4
votes
2
answers
186
views
How to remove and speed up a for loop over matrix columns by vectorisation?
Intro
Consider a tournament with four players and the following schedule:
Rd 1: 1-4, 2-3.
Rd 2: 4-3, 1-2.
Rd 3: 2-4, ---.
The usual way to display tournament results is the cross table, for example:
...
0
votes
1
answer
54
views
Why does glm_project return inverted screen positions when the camera rotates?
I'm using glm_project from cglm to project a 3D world position to screen space. The code mostly works, but when I rotate the camera, the projected screen position moves in the opposite direction.
Here'...
1
vote
1
answer
207
views
Create all possible outcomes from numpy matrices that show disjoints and subsets
Let's assume there is an event and within this event there are multiple outcomes that can co-exist.
An example would be a tennis game where A plays against B and B serves. A couple of possible ...
1
vote
2
answers
128
views
How to transform a world space position to a rotation based local space position [closed]
I have a world space position named P.
I want to compute its corresponding position in another space named let's say "L".
L is made of two components:
The world space position of its ...
0
votes
1
answer
87
views
MATLAB / OCTAVE matrix building speed question [closed]
Can someone explain to me please why
B = diag(-2*ones(m,1),0) + diag(ones(m-1,1),-1) + diag(ones(m-1,1),1)
takes 1,22 s. While
A = diag(-2*ones(1,n)) + diag(ones(1,n-1),1) + diag(ones(1,n-1),-1)
...
1
vote
1
answer
83
views
How to convert matrix of binary numbers into matrix of strings/symbols?
I have a matrix in Python consisting of 1s and 0s. As an example:
m= [1 0 1]
[1 1 1]
[0 0 1]
I would like to convert it to a matrix of symbols/strings. An example of the output I'm ...
0
votes
1
answer
110
views
Generalized eigenvalue problem in python. What am I doing wrong?
I am trying to solve the generalized eigenvalue problem, Ax=bBx where A and B are m x m matrices and I am trying to find b (which is a number) in python. I have ran into a problem. I am using eigh ...
1
vote
1
answer
44
views
Pair up elements from two differently dimensioned matrices with a nested loop
I have the following exercise involving 2 matrices – the first being ‘Equipment available to four leagues’, the second being the ‘teams per league’ (i.e, two teams per league). Note, there is ...
0
votes
0
answers
280
views
How to use Matrix API with curl
When trying to check the availability of usernames at the matrix.org server using the Matrix protocol with the following command
curl -H "Content-Type: application/json" -X GET "https://...
6
votes
2
answers
124
views
Printing numpy matrices horizontally on the console
Numpy has many nice features for formatted output, but something I miss is the ability to print more than one array/matrix on the same line. What I mean is easiest to explain with an example. Given ...
1
vote
1
answer
41
views
Getting an error while mutating a matrix this way
I am trying to find the determinant of a 4x4 matrix using nested list operations. I gave the following code
def determinant_4x4(matrix: list[list[int|float]]) -> float:
# Your recursive ...
0
votes
0
answers
42
views
Matrix Multiplication Error in MATLAB R2022 but Not in R2024 (ECEF-to-ECI Transformation)
I'm running a MATLAB script on macOS that performs sensor fusion using GNSS and IMU data. The script runs perfectly in MATLAB R2024 but fails in MATLAB R2022 with the following error during the ECEF ...
1
vote
1
answer
68
views
Identifying loops in a network diagram and converting this to node pathways in a dataframe
I'm working with networks like these:
mat1 <- matrix(
c(
-1, -1, -1, 0, 0,
1, -1, -1, 0, 0,
1, 1, 0, -1, -1,
0, 0, 1, -1, 0,
0, 0, 1, 0, -1
),
nrow = 5, ncol = 5, byrow = ...
0
votes
1
answer
50
views
How do I successfully assign a function to the on_click event?
I am new in this stuff, I am currently working in a school project about a matrix calculator, I want to enter the two matrix and that when I click a button the solution of the operation gets printed.
...
0
votes
0
answers
35
views
Find a Point by using Transformation Matrix and Inverse Tranformation Matrix
I have prepared simple code. I need to verify firstframe_center_point by using inverse second_frame_matrix and secondframe_center_point,however, there is a small mistake in my way. I have simply ...