For a C++ program which parses the dat files (any of the 14,580) which
are located in
https://beta.lmfdb.org/riemann-zeta-zeros/data/ and gives
the zeta zero values (128 bits)
You are welcome to my program, the source is provided. I used 128 bit
mpf_class floating point accuracy on the calculations.
- Randall L. Rathbun
/* C++ Parser for zeros_nnnn.dat files
NOTE: see
https://beta.lmfdb.org/riemann-zeta-zeros/README.dvi
*/
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <gmpxx.h>
using namespace std;
int main( int argc, char *argv[] ) {
streampos size;
string file_name;
union blockunion {
char charblock[8];
unsigned long blocks;
} block_header;
union tunion {
char charblock[8];
double dbl_t;
} T0,T1;
union nunion {
char charblock[8];
unsigned long ul_n;
} N0,N1;
struct zerostruct {
unsigned long top;
unsigned int mid;
unsigned char bot;
};
union zerounion {
char charblock[13];
zerostruct zl;
} zero_line;
mpz_class ninty_six("79228162514264337593543950336");
mpz_class sixty_four("18446744073709551616");
mpf_class ozo("2535301200456458802993406410752.0",128);
mpf_class one("1.0",128);
mpf_class adj = one / ozo;
if ( argc != 2 ) {
cerr << "Command: parse_zeros zeros_nnn46000.dat" << endl << flush;
return (-1);
} else {
file_name = argv[1];
}
ifstream infile;
infile.open(file_name, ios::in|ios::binary);
/* proceed with parsing if file open is successful */
if (infile.is_open()) {
/* B - number of blocks */
infile.read(block_header.charblock,8);
unsigned long blocks_in_file = block_header.blocks;
cout << "---------------------------------------------------" <<
endl;
cout << "-- Total blocks: " << blocks_in_file << " " << file_name
<< endl;
cout << "---------------------------------------------------" <<
endl;
/* iterate through blocks */
for ( unsigned long block = 1; block <= block_header.blocks;
block++ ) {
cout << "-- Block " << block << endl;
infile.read(T0.charblock,8);
double t0 = T0.dbl_t;
cout << "-- t0 = " << t0 << endl;
mpf_class mt0(t0,128); // important t_0 value for the file
infile.read(T1.charblock,8);
double t1 = T1.dbl_t;
cout << "-- t1 = " << t1 << endl;
infile.read(N0.charblock,8);
unsigned long n0 = N0.ul_n;
cout << "-- n0 = " << n0 << endl;
infile.read(N1.charblock,8);
unsigned long n1 = N1.ul_n;
cout << "-- n1 = " << n1 << endl;
unsigned long count_of_zeros = n1 - n0;
cout << "-- " << count_of_zeros << " in this block" << endl;
cout <<
"-------------------------------------------------------------" << endl;
mpz_class sum_of_zeros = 0;
for (unsigned long zeros = 1; zeros <= count_of_zeros; zeros++) {
// cout << "zero # " << zeros << endl;
infile.read(zero_line.charblock,13);
unsigned long t = zero_line.zl.top;
mpz_class mt(t);
unsigned int m = zero_line.zl.mid;
mpz_class mm(m);
unsigned char b = zero_line.zl.bot;
mpz_class mb(b);
mpz_class zero = ninty_six * mb + sixty_four * mm + mt;
// cout << " zero = " << zero << endl;
sum_of_zeros += zero;
mpf_class fsoz(sum_of_zeros,128);
mpf_class true_zero = mt0 + fsoz * adj;
cout << zeros << "\t" << "1/2 + " << setprecision(62) <<
true_zero << "*I" << endl;
} // loop over zeroes
cout <<
"-------------------------------------------------------------" << endl;
} // loop over blocks
}
else cout << "Unable to open file" << endl;
infile.close();
return 0;
}
/* Requirements:
compile line: g++ parse_zeros.cpp -Wall -O2 -o parse_zeros -lgmpxx -lgmp
requires gmp v6.3.0
https://gmplib.org/ and gcc C++ compiler std:C11
*/