Questions tagged [binary]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
1answer
80 views

Binary permutation list code in Mathematica

Given some natural number $N$, I am interested in the set of all binary permutations of length $N$ (with the intention of storing in lists depending on how many $1$'s appear in each permutation). My ...
0
votes
1answer
64 views

Minimizing a function over a bounded domain with binary variables

I want to minimize the following function: $$ f(m,n)= \sum_{i=1}^N\Big\{ \alpha_i(x_i-m)^T(x_i-m) \Big\} + \sum_{i=1}^N\Big\{\beta_i (x_i-n)^T(x_i-n) \Big\} $$ where $m,n$ are all 2-d vectors: $$ m:= ...
11
votes
1answer
285 views

What is the relationship between the Wolfram executables? Where is this documented?

The relatively new wolframscript now accompanies the traditional math and wolfram binaries. ...
5
votes
1answer
89 views

Read binary files and separate the 64-bit unsigned integers into certain forms?

I have a binary file where each data is a 64-bit unsigned integer (little endian). For simplicity, let's say the data in testdata.bin file opened in HxD is: namely:...
2
votes
1answer
128 views

How do I get the data from this binary file? [duplicate]

I have a file which contains the following binary data: ...
4
votes
2answers
121 views

How to generate the 8^th order symmetric binary matrices whose sum of absolute eigenvalues is 8?

It is needed to generate all 8th order(8 by 8) symmetric binary matrices(of 0's and 1's) such that the sum of the absolute eigenvalues is 8. Listing all the 8th order symmetric binary matrices and ...
0
votes
0answers
26 views

FindClusters Hamming Distance giving error

I am trying to run FindClusters[hex, DistanceFunction -> HammingDistance[IntegerDigits[#, 2, 8], IntegerDigits[0, 2, 8]] &] over a list of data but I keep ...
0
votes
1answer
46 views

Import and create a hexdump view of file

How would I go about creating a hexdump type of view of an imported binary file? for example, (format is ...
1
vote
0answers
44 views

Reading product of same ByteArrays

I am handling a huge set of data and I am trying to optimize my code. I have very large expressions to expand and simplify and I've seen that converting the expressions to ByteArrays improves a lot ...
4
votes
4answers
241 views

Generating all symmetric binary matrices of order up to 7?

I want to create all symmetric binary matrix with order up to 7. Can anybody help in creating this? I want to obtain the subset of all symmetric matrices, with all diagonal entries being zero.
2
votes
3answers
165 views

Simplifying expressions containing binary variables

Consider an expression with two binary variables, $a,b\in\left\{ 0,1\right\} $, given by $F=(1-a-b)^{3}(1-b)$, with truth table: ...
0
votes
2answers
50 views

FindMaximum under binary constrains

I'm trying to find a maximum for a function whose variables have binary values (either -1 or 1). The clumsy code for that constraint I use is shown below. There must be a more compact code, and I ...
0
votes
0answers
40 views

Table Glitch / Error with binary data

I have a large group of binary files that I am loading with binaryList = Table[ BinaryReadList[ paths[[i]], "Byte"], {i, Length@paths}]; specifically ...
1
vote
1answer
136 views

Import OVF 2.0 Vector field files

I'm using a simulation software (mumax3) which outputs OVF_2.0 files. It can either export binary or text files. The binary files are usually much smaller than the text files. I would like to use the ...
11
votes
7answers
2k views

Find if there are consecutive 1s in a binary representation of a number

Given a list of numbers in decimal form, what is the most efficient way to determine if there are any consecutive 1s in the binary forms of those numbers? My solution so far: ...
1
vote
1answer
84 views

Construct a binary tree where nodes are labeled according to given rule

I want to plot a binary tree in Mathematica where the nodes are labeled according to a given rule. In fact, whether a node has a left child or a right child or both, will be determined by a rule. And ...
1
vote
1answer
81 views

How to understand and use bit operation for programming

I got the following code using bit operation from here: ...
6
votes
0answers
108 views

Importing a 12 bit array

I have a binary file of 12 bits integers obtained from a camera software. It can produce FITS files from these but the processing time on the large data set I have is excessive. What I have is the ...
1
vote
0answers
65 views

How to recover plaintext from .MX files?

I need a function to deserialize the contents of an MX source file for reading. We can’t simply use Get because I don’t want to load or run the code, but rather to ...
12
votes
0answers
456 views

Why does Mathematica consume so much memory when reading binary data?

There are somewhat similar questions on here, but I didn't find a satisfying answer for this case: I import a 1.7 GB binary data file using the following command: ...
1
vote
1answer
139 views

Why ImportByteArray when generate image from bytes

I was trying to generate an image from a list of bytes so I only had to Import an Image once as I want to store a Base64Encoded ...
5
votes
0answers
58 views

Does NumericArray always maintain data unmodified?

Suppose that we create a NumericArray using a LibraryLink function, then pass this to another one. Is NumericArray guaranteed to maintain the binary data as it was ...
3
votes
1answer
283 views

Read NumericArray from a file

Suppose I have a binary file which consists of a list of integer or real numbers. Let's say signed 8-bit integers; so each byte of the file is a single such integer. How can I read it and turn it into ...
4
votes
1answer
111 views

Something is wrong with the implementation of the ThueMorse function

While trying to answer this Math.SE question, I believe I found several bugs in Mathematica and Alpha relating to the Thue-Morse sequence. As a quick reminder, the $n^{\rm th}$ element of the Thue-...
7
votes
4answers
782 views

BitNot does not flip bits in the way I expected

Can anyone explain why the last result in these statements is not the bit-flipped version of arr? ...
3
votes
0answers
245 views

How to import a binary data generated by Fortran? [closed]

I have a unformatted binary data file generated by gfortran. However, when the binary data is imported by Mathematica, a correct result is not obtained. This is my fortran code: ...
2
votes
2answers
117 views

Listing all monotone increasing binary digits

For $n=5$, I have $32$ binary digits and for this there are $2^{32}$ combinations. Out of this many, the interesting ones (i.e., the ones that have monotone increasing binary digits) are only about "$...
1
vote
2answers
172 views

Number of contiguous ones of an element in a 2d binary array

I have a 2d binary array of 0s and 1s. I select an element and would like to know how many 1s are in the contiguous cluster that includes the selected point. If the selected element is 0, the answer ...
0
votes
1answer
506 views

Using the binary search algorithm in a sorted grid

I want to get a mathematica code for binary search algorithm applied to a sorted grid containing integers. For example, given f[k_,x_]= x^2 + k x + k - 2 where <...
4
votes
1answer
945 views

How to read this dataset with .dat and .r64 files?

I stumbled upon the European Data Incubator project, and wanted to play around with some of their data. I'm trying to open this dataset, which contains a bunch of ...
2
votes
0answers
341 views

Converting hex string to ByteArray

With blockchain support, it should finally become straightforward to convert string hashes to ByteArray, but I still can't figure out the canonical Wolfram way of ...
2
votes
1answer
169 views

Generate a prime number in a range with fixed $n$ most significant bits

I'm new to Mathematica so my question might be trivial. How do I generate a $200-bit$ prime with the condition that the 10 most significant bits in its binary representation are equal to some binary ...
4
votes
4answers
751 views

How to total the amount of zeros in a binary matrix

I have a 150 by 300 binary matrix. I would like to find the total amount of zeros in the matrix. I've been consulting online documentation for support, but am unable to use the "count" function ...
1
vote
0answers
61 views

Efficiently transform sequentially generated integer matrices into boolean matrices

Assume you have a list of 5 numbers, eg L = {14, 7, 11, 14, 0};. Now, what you want to do with this list, is to transform each entry into eg a binary list, using <...
6
votes
1answer
232 views

Is it possible to convert the output of the Encrypt[] function into binary digits?

I use the following code to generate a key and then use it to encrypt a simple string message. The output of the function Encrypt is an encrypted object. But I would rather convert this into binary ...
2
votes
1answer
344 views

The binary of negative integer number

I have a question about the binary of negative integer number in Mathematica. In most implementations, negative signed integers are stored in what is called two's complement. The other major way of ...
2
votes
1answer
130 views

Convert Negative Integers into Signed Binary?

I'm relatively new to Mathematica and have been struggling with this problem for several days. I have a string of integer data, ranging from -2044 to 2044. So this looks something like {-2044,-2040,-...
3
votes
1answer
270 views

Convert characters to binary?

I can get a binary representation of characters as follows: BaseForm[ToCharacterCode["A"], 2] However, that produces a weird binary code object that might be ...
9
votes
8answers
593 views

How to find the sum for each individual row in a binary matrix until the first zero is reached from left to right.

I have a 150 by 300 binary matrix. I would like to sum the 1's for each individual row (from left to right) until the first zero is encountered. For example, if a given row is 1 1 1 1 1 1 0 0 0 1 0 0 ...
10
votes
5answers
897 views

Substitute some 1s with 0s in random list

How is it better to substitute list of random combination of 1 and 0 (binary image) so that only first (or central) instance of 1 left in each group. ...
5
votes
2answers
388 views

Printing binary numbers with extra zeros

I have the numbers $0-64$ in binary and want them all to be displayed with 8 figures. Expected output: $5_{10} = 101_2$ should become 00000101.
1
vote
0answers
48 views

Binary Image Size after import

I have a lot of binary images I would like to import into mathematica. Each of them is 132kB (1024x1024) big. Like the following: As soon as I import it into Mathematica however and call ByteCount[...
1
vote
0answers
65 views

Export 1bit Image

I have a binary image like the following one: How can I export it as an 1bit image instead of an 8bit one? If I export it in tiff it automatically becomes an 8bit one. Best, Max
0
votes
5answers
117 views

How to find all binary numbers with the kth =0 and smaller than 2^n?

I have been stuck in this problem for a long time. I need to find a general code to collect all binary numbers which are at most n digits (<2^(n-1)) with the ...
5
votes
1answer
326 views

Decoding GZIP encoded Body, BodyBytes (ByteArray) and BodyBytesArray from URLRead

When calling the Stack Exchange API v2.2 using the new (Mma11) function URLRead we get a GZIP encoded Body in alternative formats: ...
12
votes
1answer
231 views

Performance-driven approach to using Big Data without killing the hard-drive

Situation A calculation has to be done in which the amount of data is too much to fit into memory. Fortunately, only a part of the overall data set has to be known at a time. The preprocessing is ...
1
vote
1answer
390 views

Generate a list of randomly distributed $1$s and $0$s with fixed proportion of $1$s [duplicate]

I need to simulate a random initial state of an 1D cellular automaton, but with different 'densities' of filled cells. Let's say the size of the list is $N$, then I need to be able to fix a number $P$...
8
votes
3answers
457 views

Reading a file as a ByteArray?

I want to read in large files as byte strings. Import[..., "Byte"] yields a list of Integers that takes up much more space (16 times more) than the file. ...
1
vote
0answers
161 views

How can I import Real16 binary data? BinaryReadList doesn't work [closed]

How can I import Real16 binary data? BinaryReadList doesn't work: ...
-1
votes
1answer
110 views

Turn binary number into string of words [closed]

I don't actually have any code for this, as I have no real idea how to do it. I have a large binary number combination that I know turns into some sort of string. How would I go about translating it?