Questions tagged [binary-matrix]
54 questions
1
vote
1 answer
Finding the number of 0s in a number of binary matrices in the same directory?
I am trying to get the number of 0s (or count of) in a number of binary matrix csv files? Is there an efficient way of doing this for multiple csv files at once?
I have read in all the csv files from the set working directory using this code but I…

Lynda
- 141
- 7
1
vote
1 answer
All possible binary matrices with some properties
I need to generate all possible 4x4 binary matrices that have zeros along the main diagonal, are symmetric, and have six entries equal to 1. Some examples:
[[0,0,0,0],
[0,0,1,1],
[0,1,0,1],
[0,1,1,0]],
[[0,1,1,0],
[1,0,1,0],
[1,1,0,0],
…

MathNew C
- 11
- 3
1
vote
0 answers
Inverse of a binary matrix in C
I have a binary matrix (zeros and ones) D[][] of dimension nxn where n is large (approximately around 1500 - 2000). I want to find the inverse of this matrix in C.
Since I'm new to C, I started with a 3 x 3 matrix and working around to generalize it…

Cherry
- 23
- 1
- 7
1
vote
1 answer
Tensorflow compute multiplication by binary matrix
I have my data tensor which is of the shape [batch_size,512] and I have a constant matrix with values only of 0 and 1 which has the shape [256,512].
I would like to compute efficiently for each batch the sum of the products of my vector (second…

Codevan
- 538
- 3
- 20
1
vote
0 answers
Create a binary matrix where columns equals rows
I am trying to run a regression of a list of bond's values against the credit (S&P) rating of the bond. For that I am trying to create a binary matrix of where the columns (a list of all available S&P credit rating [AAA, AA+,..., BBB-, etc..]). My…

Banana Republic
- 11
- 2
1
vote
1 answer
Columnwise removal of first ones from binary matrix. MATLAB
I have some binary matrix. I want to remove all first ones from each column, but keep one if this value is alone in column. I have some code, which produces correct result, but it looks ugly- I should iterate through all columns.
Could You give me a…

zlon
- 812
- 8
- 24
1
vote
1 answer
Most efficient way to work with HUGE binary matrix?
I have a huge binary matrix, like 100000 x 100000.
Reading this article http://www.cs.up.ac.za/cs/vpieterse/pub/PieterseEtAl_SAICSIT2010.pdf, I seemed to understand that the best tradeoff to memorize and work with a binary matrix is using…

Draxent
- 500
- 1
- 6
- 14
1
vote
1 answer
How to efficiently store and manipulate sparse binary matrices in Octave?
I'm trying to manipulate sparse binary matrices in GNU Octave, and it's using way more memory than I expect, and relevant sparse-matrix functions don't behave the way I want them to. I see this question about higher-than-expected sparse-matrix…

hoc_age
- 1,945
- 2
- 18
- 28
1
vote
1 answer
In Matlab: make mask from volume's outline
I've been struggling for a while to find a good solution to the problem described below. I want to avoid for loops but feel my Matlab skills are inadequate to do otherwise. I have a 3D position matrix of size 329x230x105. This defines a 3d volume of…

user1641496
- 457
- 1
- 8
- 18
0
votes
1 answer
octave binary matrix for gnuplot
I need help in understanding how to use this octave script
http://www.gnuplotting.org/code/save_binary_matrix.m
to generate a binary matrix that I want to plot with gnuplot. Any suggestion will be appreciated even just a web link that would help me…

Mareczek
- 304
- 1
- 2
- 13
0
votes
1 answer
Generation of matrix with sum 1 for each row and at least 1 assignment for each column
How can I create a binary matrix where each column sums to 1 and in the columns is >= 1?
I need to build n*m matrices to perform assignments in an algorithm.

user21559
- 7
- 2
0
votes
2 answers
Masking the columns of pytorch matrix
I have a matrix of shape (batch_size, N, N) and a masking tensor of shape (batch_size, N).
I want to put -infinity values only for the columns (and not rows) of the matrix, according to the given mask.

Codevan
- 538
- 3
- 20
0
votes
0 answers
Enforce binary coefficients in Logistic Regression
I am facing a classification problem in which I need to classify samples based on the presence or absence of features.
The data matrix X is a binary scipy.sparse.csr_matrix.
I tried to fit a LogisticRegression with penalty='l1' and C=0.5, which…

Damien Lancry
- 85
- 10
0
votes
1 answer
Existence of path in binary matrix with specified directions
I have a binary matrix (N*M) filled with 0 and 1. Example:
(S, 1, 1, 1, 0)
(1, 0, 0, 0, 1)
(1, 1, 0, 0, 1)
(1, 0, 1, 1, D)
The Startpoint S is the top-lefthand-corner and the Destination D is the buttom-righthand corner.
Starting at S the following…

Dom
- 17
- 4
0
votes
0 answers
Coder for a Hamming code of arbitrary length (binary matrix-vector multiplication, on a CPU, platform independent)
The problem seems quite suited for a GPU, FPGA, etc. (because it's quite parallel); but I'm looking for a CPU-based and somewhat architecture independent solution right now. I think a good answer could be just some unimplemented pseudo-code, but my…

user2373145
- 332
- 2
- 14