4,645 questions
1
vote
1
answer
61
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) ...
3
votes
0
answers
79
views
Returning mutable references and lifetime in rust [duplicate]
I am trying to develop a linear algebra library in rust. So, as part of it I am writing code that iterates through a n-dimensional array and returns mutable references. It's like writing a view for a ...
0
votes
0
answers
44
views
How to do a lattice attack on Linear recurrence relations using least significant byte?
Lattices are hard for some of us who heard from the infamous lattice attack on ECDSA, but now i am in a situation where understanding it will be much helpful.
I have the following
k0 = 0x447B846F ...
0
votes
1
answer
98
views
scipy.linalg.eig(L) gives imaginary parts that shouldn't be there
I am trying to compute the eigenvalues, left, and right eigenvectors of a Laplacian matrix in Python.
Here is my matrix:
lap = [[-2. 1. 0. 1.] [ 1. -2. 1. 0.] [ 0. 1. -2. 1.] [ 1. 0. 1. -2.]]
I ...
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, ...
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/...
6
votes
1
answer
135
views
What is wrong with my block GMRES implementation?
I'm trying to implement a block GMRES procedure (i.e., GMRES to solve Ax=b, but with b that is not a vector but a n x r matrix, where r << n). My goal is to have a first implementation in Python ...
0
votes
0
answers
46
views
Applying lattice attack on Truncated Linear Conguential Generator efficiently?
I took interest on the project that someone was working on and in theory it should work but after putting it in code the results aren't as expected.
The equation:
k_i = (k_{i-1}+x_i)*const + 1 mod ...
1
vote
0
answers
106
views
Computing the dot product of a matrix in MatLAb
I am trying to compute the dot product of a matrix in Matlab. The algorithms in each problem were generated using this website.
To do so, I am required to use the function I created in the previous ...
2
votes
3
answers
96
views
Unfolding a cartesian binned dataset into polar coordinates
I have a dataset of binned events, corresponding to a cartesian coordinate set
[[ 0. 0. 0. 0. 0. 0. 2. 5. 2. 3. 3. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 4. 10. 9. 7. 10. 6. ...
1
vote
1
answer
63
views
Matrix Multiply with Vector and Tensor in Python
I have a Vector, M, with size N and a Tensor, d, with size NxNxD.
My aim is to perform the matrix multication M*d[i,:,:] for each i to get a new matrix with size nxD.
Now I could just do it like this:
...
0
votes
1
answer
74
views
Trying to rotate a gizmo to be flush with one of the sides of a cube
I am making a small block builder with physics in Bevy, just for fun and for learning purposes. I guess my issue boils down to basically a math problem. I am trying to rotate the block placement ...
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 ...
0
votes
0
answers
44
views
How to extract basis from equation for a lattice attack?
I have a problem which require lattice attack at some point to reduce work load but for most of use lattices are hard to understand.
I have:
k1 = (k0+x1)*const +1
k2 = (k1+x2)*const +1
k3 = (k2+x3)*...
0
votes
1
answer
71
views
Is there a way to impose an ordering on eigenvalues from a parametrized matrix? [closed]
I have a 3x3 matrix, call it H, dependent on the parameters f, B. I then let f range from 0 to pi, and for each take the eigenvalues of H(f) using numpy's function: numpy.linalg.eig(). This gives me a ...
1
vote
1
answer
81
views
How to Efficiently Solve Millions of Independent 2x2 Linear Systems with Augmented Matrices
I need to solve millions to tens of millions of independent 2-variable linear systems represented in augmented matrix form. The input consists of coefficient vectors A, B, C, A', B', C' (each ...
1
vote
1
answer
75
views
Reducing to Hessenberg form using Givens rotations
I'm trying to implement a function in Python that reduces a square matrix to upper Hessenberg form using Givens rotations. I know that this should be possible Wiki and sometimes preferred over ...
4
votes
0
answers
96
views
Issues with computing determinant of high dimensional symbolic matrix
I am trying to solve the equation,
|λ²·A + λ·B + C| = 0,
where lambda is a (possibly complex) scalar and A, B, and C are N x N matrices. The goal is to compute the roots of the characteristic ...
2
votes
0
answers
202
views
How to reuse cuDSS factors when solving a system of linear equations Ax=b
I am using cuDSS to solve a set of Ax=b equations as follows
cudssMatrixType_t mtype = CUDSS_MTYPE_SPD;
cudssMatrixViewType_t mview = CUDSS_MVIEW_UPPER;
cudssIndexBase_t base = CUDSS_BASE_ZERO;
...
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 ...
0
votes
0
answers
62
views
Correct Depth Ordering for Isometric Rectangular Prisms in a 2D Game (Avoiding Z-Fighting for Irregular Shapes)
As a preface this is not a question asking for code, I am simply seeking a process, or math formula.
I'm working on a 2D game that has an isometric perspective to simulate a 3D world.
The objects in ...
0
votes
1
answer
64
views
How to calculate the derivate of a python pandas dataframe given vector values and coordinates?
Say I have three scaler components (Vx, Vy, Vz) of some value V, as well as the 2D location coordinates where these values exist (x, y). This is arranged in a pandas dataframe (df) such that the data ...
0
votes
0
answers
40
views
Rotating a movement vector by camera and character rotation
I am working on my first project with Godot (and in Gamedev in general).
I am now trying to configure animations for my character in an isometric 3d game.
Inside of AnimationPlayerTree, I have an ...
0
votes
1
answer
64
views
Time complexity of summing m vectors of length n
I know this is a simple question, but I'm thrown off by some additions related to linear algebra problems being treated as constant time vs. linear time. In this case, I'm interested in summing m ...
-1
votes
1
answer
106
views
Computing the Camera Ray’s Pitch Angle in different coordinate frames
I would like to calculate the pitch angle of a camera ray vector that corresponds to an image point (u,v). This vector is moved to plant coordinate frame and named as Reflected_Ray vector.
How to ...
2
votes
0
answers
100
views
How to convert camera space to world space given Camera Vector and Ray vector in camera space
How can i convert a camera space vector to world space, given the camera direction vector, and the camera space vector?
All vecs are normalized 3D vectors, and the camera space projection is correct ...
0
votes
0
answers
39
views
Is there an efficient approach in PyTorch for multi-output regression where inputs alternate every other feature (i.e., without using a for loop)?
I'm looking for the fastest way to essentially predict a rotating n values using, effectively, the other n-1 features. I can conceptualize a way of doing this with a for loop and will explain it below....
0
votes
0
answers
99
views
Numba np.linalg.eigvalsh exception raised inconsistenlty
I'm using numba to compile some expensive calcualtion for signifcant performance gains - this is wonderful! Recently I made a small change to the calcualtion to extract some additional values (...
0
votes
2
answers
154
views
Inverse of a matrix with variables instead of values
Multiplying
a <- matrix(c(0,0,0,0), nrow = 2, byrow = TRUE)
b <- matrix(c("b1","b2","b3","b4"), nrow = 2, byrow = TRUE)
a %*% b
gives
Error in a %*% b :...
0
votes
0
answers
96
views
Quadruple precision complex matrix diagonalization in Fortran 90
I'm writing a code that mostly consists of matrices manipulation and, in particular, diagonalization. I already have a code, both in python and in Fortran 90 that are able to solve my problem in a ...
0
votes
0
answers
81
views
Ew resizing rotated rectange in html canvas
I'm trying to resizing a rotated rectangle in html canvas. The direction of resizing is to east, so basically, the rectangle width must grow, while it mantains the height fixed.
I achieved to do it in ...
0
votes
0
answers
38
views
Trying to obtain coefficient matrix of Bspline matrix then obtaining its quasi-diagonal matrix?
I tried to obtain the coefficients of B-spline matrix using the following code:
function C_matrix = calculateBsplineCoefficientMatrix(s)
% Number of input samples
N = length(s);
% Construct Alpha ...
3
votes
1
answer
169
views
Numpy/scipy - How to find the least squares solution with the constraint that Ax >= b?
I have a linear algebra problem that I can't find the correct function for; I need to find the vector x that satisfies Ax = b. Because A is non-square (there's 5 columns and something like 37 rows), ...
1
vote
1
answer
89
views
JavaScript - Is there an efficient way to check if an integer "k" is a linear combination of the values in an array of prime numbers?
I have an arbitrarily large integer k and an array of arbitrarily many positive prime numbers [p_1, p_2, ..., p_n]. Using JavaScript, I want to check if k can be expressed as a linear combination of ...
0
votes
0
answers
125
views
Is there a way to use Enzyme.jl to auto-differentiate a matrix inverse?
I am new to auto-differentiation in Julia and have been trying to use Enzyme to compute the gradient of a custom function that involves a matrix inverse. I have come across the problem that Enzyme ...
2
votes
2
answers
115
views
Why does my finite difference weights calculation for Taylor series give incorrect results?
I'm trying to calculate the weights for a finite-difference approximation of the first derivative f′(x)f'(x)f′(x) using the Taylor series expansion. I'm solving for weights a,b,c,d,ea, b, c, d, ea,b,c,...
0
votes
0
answers
61
views
How can I modify this Lights Out solver algorithm to account for an arbitrary number of missing tiles?
My code: https://jsfiddle.net/03t2wdrq/
// based on https://www.keithschwarz.com/interesting/code/?dir=lights-out
var puzzle = [];
var toggle = [];
var solution = [];
// initialize toggle matrix ...
0
votes
1
answer
72
views
Why do we need to use homogenous coordinates for camera/world coordinates during perspective projection?
I understand that in order to project a point in camera coordinate system (which is in 3d) onto image coordinate system (which is 2d), we need to use homogenous coordinates for the image coordinates ,...
0
votes
1
answer
114
views
pycddlib for finding all vertices in a polytope, python
I attempted to use **pycddlib ** to find vertices in a polytope with Python. I followed the code in this post.
Polytope, Python - find extreme points
import numpy as np
import cdd as pcdd
A = np....
0
votes
0
answers
60
views
Kalman Filter Issue: Gyroscope Measures Delta Rotation but AoA is Absolute Angle
I'm working on a project where I'm combining gyroscope data (which measures delta rotation) with AoA (Angle of Arrival) measurements (absolute angles in degrees) using a Kalman filter. The goal is to ...
0
votes
0
answers
61
views
C# SharpDX, Quaternion Squad not continue
I'm using SharpDX to perform Squad interpolation of quaternions, but the calculated results are not continuous. Here is the code. What is the issue, and how can I fix it?
The following graph ...
1
vote
1
answer
128
views
Solve (underdetermined) linear system with commutator form in Python
Consider three (complex) square matrices A, X, and B, that form a generally underdetermined linear system
A @ X - X @ A == B
The system is to be solved for X. I would like to use, e.g., the lstsq ...
1
vote
1
answer
394
views
Camera pose estimation using opencv's solvePnP
I have a grayscale camera for which I have already calculated intrinsic parameters with standard methods of calibrations. I have then position this camera in a particular stationary setup and put a ...
1
vote
2
answers
214
views
Python matrices in GF(2)
I want to manipulate matrices of elements of the finite field GF(2), where every element is a 1 or a 0, in Python. I see that numpy can use dtype=bool, but it uses saturating addition, not wrapping, ...
0
votes
0
answers
84
views
Efficient solution of A @ X = B with B a triangular matrix in scipy or numpy
Consider three square matrices A, X, and B that form the linear system:
A @ X = B
to be solved for a particular solution X (which might not be unique).
I know that the matrix B is a triangular matrix....
0
votes
0
answers
36
views
Estimating Tag Position from Distance and Angle of Arrival Measurements with only Anchor Rotation
I'm working on a problem involving positioning in a 2D space and need some help understanding why my approach isn't always working.
I have:
An anchor located at the origin $(0, 0)$.
A tag at an ...
3
votes
2
answers
52
views
R stats `aov` uses all available cores instead of just one
I’m analysing the impact of a covariate on a dependent variable using aov to assess how much variation can be reduced by including said covariate.
However, when I run the function, it automatically ...
1
vote
1
answer
93
views
Why does this implementation of the Block Tridiagonal Thomas algorithm give such large errors?
See below my attempt at implementing the block tridiagonal thomas algorithm. If you run this however, you get a relatively large (10^-2) error in the block TMDA compared to the np direct solve (10^-15)...
4
votes
2
answers
173
views
Eigen + Spectra - numerical artifacts and finding smallest Eigenvalues
I'm trying to find eigenvalues for a family of matrices (Hamiltonian with perturbation).
Matrix is equal to sum of diagonal matrix "mat1", and another matrix "mat2" multiplied by a ...