Questions tagged [binary-matrix]

54 questions
7
votes
2 answers

Binary matrix vector multiplication

I want to multiply a 8x8 binary matrix represented as a unsigned 64 bit integer by a 8 bit vector represented by a unsigned char. However, due to some other issues the matrix must be ordered by columns, ergo there's no easy matching of bytes for…
Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
6
votes
3 answers

R:Binary matrix for all possible unique results

How to generate a binary matrix for all possible permutations of 'i' variables X, where " i " can be any number between 1 and infinite. Resultant matrix will have 2^ i unique rows. For i=2 , variables x1, x2 each with a possible value of 1 or 0, so…
Chandra
  • 526
  • 2
  • 9
  • 26
5
votes
1 answer

Biclustering in R

I want to apply byclustering on a binary matrix in R. There is a nice package called "biclust" available, but it does and displays not everything that I want. I have a binary matrix which looks like the following: 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0…
Robbert Raats
  • 259
  • 3
  • 18
4
votes
1 answer

Algorithm to generate a binary matrix

Given two input arrays [R1, ..., Rn] and [C1, ..., Cn]. We want to create a binary matrix A (of size-nxn) such that the sum of elements in column i of A be Ci and the sum of elements in row j of A be Rj. I tried to fill using greedy algorithm : fill…
Mike
  • 61
  • 9
3
votes
2 answers

How to plotting binary matrix only 1(one) elements in R

I have a sparse matrix .csv file and save the Matrix like: v1 v2 v3 v4 v5 v6 ... vn 1 0 1 0 1 0 0 2 0 0 0 1 0 0 3 0 0 0 0 1 0 4 1 0 0 0 0 1 5 1 0 1 0 1 0 ... m I want make plot's x value = v1~vn , y value = 1~m and marking…
3
votes
2 answers

Python Pandas: How to create a binary matrix from column of lists?

I have a Python Pandas DataFrame like the following: 1 0 a, b 1 c 2 d 3 e a, b is a string representing a list of user features How can I convert this into a binary matrix of the user features like the following: a b c…
jfive
  • 1,291
  • 3
  • 14
  • 21
3
votes
2 answers

Given a boolean matrix sorted row wise. Return a row with max number of 1

I came across a problem of Matrices but was trying to figure out the optimal solution. Problem statement is the question topic itself. Further see below Example Input matrix 0 1 1 1 0 0 1 1 1 1 1 1 // this row has maximum 1s 0 0 0…
roger_that
  • 9,493
  • 18
  • 66
  • 102
2
votes
1 answer

How to get all unique permutations of a binary matrix with 6 columns and 12 rows?

I am trying to produce all possible binary matrices order 12x6 containing elements only -1 and +1. There are 2^72 unique matrices (2^16), such that no two matrices contain the same element in the same coordinates. I tried with the below…
Darsh
  • 21
  • 1
2
votes
3 answers

R: how to convert a sparse binary matrix represented by row-indexed lists to column-indexed lists

Assuming I have a sparse m by n binary matrix, and I already use a row-indexed lists to represent the ones. For example, the following 3 by 3 matrix [,1] [,2] [,3] [1,] 1 1 0 [2,] 0 1 0 [3,] 0 0 1 is represented by a…
Zhuzhu
  • 21
  • 3
2
votes
2 answers

How to create expression input style format from binary table/matrix?

I have a binary table like this in my R script: >class(forCount) [1] "table" >forCount Gene Filename CTX-M-27 IMI-1 IMP-39 IMP-4 KPC-2 NDM-1 batch0_01032019_ENT1 0 1 0 0 0 1 batch0_01032019_ENT2 …
2
votes
1 answer

Find number of ‘+’ formed by all ones in a binary matrix

The question I have is similar to the problem found here: https://www.geeksforgeeks.org/find-size-of-the-largest-formed-by-all-ones-in-a-binary-matrix/ The difference is the '+' must have all other cells in the matrix to be zeros. For…
2
votes
1 answer

Project a multi-class array into a binary matrix

I have a simple numpy array (e.g. [1,4,2,3,1]) and want to project it into a binary matrix, where each value in the array maps to an indicator in that column of the matrix. For example, this array would map to a matrix like: [1], => [1,0,0,0], [4], …
Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
2
votes
2 answers

Element-wise binary value concatenation of two matrices

Element by element, I want to concatenate binary values from different matrices to one matrix. For example, |1 0 0| |0 1 0| |10 01 00| |0 1 1| |1 1 0| = |01 11 10| |1 0 1| |0 0 1| |10 00 11| How can this be done?
Michael
  • 33
  • 7
1
vote
1 answer

Memory address overlap of two arrays

I'm working on binary matrices. Two of my arrays are getting overlapped. (I checked the addresses).This happens only for few sizes of matrices. Hence I get wrong results. I tried using new to allocate arrays, but I get segmentation fault when I do.…
captain
  • 815
  • 14
  • 26
1
vote
1 answer

How would I find (and output) the position of the first value of 1 and the last value of 1 by row in a number of csv files at once?

I am trying to output the position of the first value of 1 and the last value of 1 by row in a number of binary matrices stored in multiple csv files at once? I have the following used to read in all tab-delimated csv files in the working…
Arron
  • 25
  • 7
1
2 3 4