41,216 questions
Advice
1
vote
6
replies
145
views
Ai Neural Network | C++ | Project Guidance --- Matrix Part
I’m an undergraduate CS student working on a final project due in about a month, and I’m trying to design and implement a C++-based AI Neural Network Simulator integrated into a small game environment....
-2
votes
3
answers
237
views
Transform Nested List of Matrices into 4D Array
Background
I am developing an R program that hierarchically tabulates data in the command line. In the spirit of cli and its box-styles, I have created a nested list with the appropriate box-drawing ...
4
votes
3
answers
159
views
Extract Matrix of Values from Matrix using Matrix of Row Numbers
I wish to efficiently extract values from a matrix (vals), using a single column number (val_col) and a matrix of row numbers (val_rows). Specifically, I also want my results in a matrix ...
0
votes
0
answers
27
views
Ffill on a pivot matrix fills in the wrong direction. How to forward-fill along the date axis?
I'm processing factor data. The raw table is in long format (ticker + date + factor_val), and some tickers are missing on certain dates (e.g. trading halts). I use pivot by to reshape it into a wide ...
Best practices
1
vote
4
replies
140
views
Dynamically Expand Matrix "In Place"
Question
What is the most efficient way of dynamically appending a single row to a matrix, when the dimensions are not known ahead of time? Ideally we modify "in-place" rather than re-...
4
votes
0
answers
231
views
A question about computing upper Hessenberg form of square matrices in C : Avoiding costly matrix multiplication
Upper Hessenberg forms are used in eigenvalue computation. I wrote the following code that transforms a square matrix to its upper Hessenberg form using an algorithm described in this video.
#define d ...
0
votes
1
answer
45
views
How to preserve row indices when converting an indexed matrix to a table?
I currently have an index matrix that I want to convert into a data table, and store the corresponding indices as fields in the data table. I tried using the table() function to achieve this, but when ...
8
votes
5
answers
912
views
How to generate a matrix with every offset of vector without using a for loop
For a given vector like v <- c(1,3,7,2,5), I want to create a matrix that repeats that vector with every possible offset, like this:
NA NA NA NA 1
NA NA NA 1 3
NA NA 1 3 7
NA 1 3 7 2
1 ...
3
votes
1
answer
159
views
Unbalanced diagonal matrix from a symmetric matrix
I want to find the eigenvalues of a symmetric matrix.
When I do this in Python, I get an unbalanced diagonal matrix. The value of [0, 0] is much larger than the other eigenvalues.
Is it wrong?
How ...
Advice
0
votes
1
replies
60
views
Leslie Matrix Simulation Coding
I'm trying to run some leslie matrix simulations for a project I'm currently working on. Basically, I'm trying to investigate the effects of different harvesting regimes on a population by creating a ...
4
votes
3
answers
286
views
Triangulating matrices using LU decomposition method in C : Question about for loop optimization
Matrices can be triangulated using less than ten lines of code in C, I have heard being said. But LU decomposition method needs to be used, instead of Cramer's rule. So, I was trying to do that. My ...
3
votes
2
answers
163
views
Algorithm find specific cells in binary matrix [closed]
In a boolean matrix there are patterns of connected cells filled with "1". The rest is filled with "0".
The goal is to get a list of cells with the red "1"s - see image ...
Best practices
2
votes
6
replies
247
views
Forwarding C-style struct matrix to constructors of same-size matrix of objects
Suppose I have a C-style matrix of elements
typedef struct _RAW_DATA{
int a;
int b;
}RAW_DATA;
inside a templated class, that defines the size of the matrix:
template<size_t TDim>
...
1
vote
1
answer
125
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
164
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:...