int main(int argc, char** argv) { int l=5; TinyVector<double,3> pos(0.1,0.3,-0.45), deltax(0.0001,0.0,0.0), deltay(0.0,0.0001,0.0), deltaz(0.0,0.0,0.0001), tpos, g; if(argc>1) l = atoi(argv[1]); if(argc>4) { pos[0] = atof(argv[2]); pos[1] = atof(argv[3]); pos[2] = atof(argv[4]); } SphericalTensor<double,TinyVector<double,3> > Y1(l,true), Y2(l,true), Yp(l,true), Ym(l,true); Y1.evaluate(pos); std::cout.setf(std::ios::scientific, std::ios::floatfield); for(int lm=0; lm<Y1.size(); lm++) { std::cout << lm << std::endl; std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] << std::setprecision(12) << Y1.gradYlm[lm] << std::endl; //std::cout << std::setw(20) << std::setprecision(12) << Y2.Ylm[lm] // << std::setprecision(12) << Y2.gradYlm[lm] << std::endl; } // for(int lm=0; lm<Y1.size(); lm++) { // tpos = pos+deltax; Yp.evaluate(tpos); // tpos = pos-deltax; Ym.evaluate(tpos); // g[0] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // tpos = pos+deltay; Yp.evaluate(tpos); // tpos = pos-deltay; Ym.evaluate(tpos); // g[1] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // tpos = pos+deltaz; Yp.evaluate(tpos); // tpos = pos-deltaz; Ym.evaluate(tpos); // g[2] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // std::cout << lm << std::endl; // std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] // << std::setprecision(12) << Y1.gradYlm[lm] - g << std::endl; // } }
// // ГОСТ 30.310-95 - генерація простих чисел. // Всі позначення змінних і пунктів взяті безпосередньо із ГОСТа. // void Gost() { srand(static_cast<unsigned int>(time(NULL))); stringstream ss; MyBigInt N("0"); //пункт 9: MyBigInt Ps("2"); int s = 0, i = 0; double t = num_of_bits; // пункт 1: //unsigned int y0 = rand(); unsigned int y0 = 24265; //int c = rand(); int c = 7341; if (c % 2 == 0) c += 1; // пункт 2: while (t >= 17) { t /= 2; i++; } s = i; s--; // пункт 3: Ps - поідеї найменше число n-bit ss << static_cast<int>(t - 1); Ps.set_value(Ps^ss.str()); ss.str(""); MyBigInt tempo(Ps); while (true) { if (Miller_Rabin(tempo) == "0") { Ps.set_value(Ps + static_cast<MyBigInt>("1")); tempo.set_value(Ps); } else { system("cls"); break; } } // пункт 4: int m = s; // пункт 5: Jump5: double rm = t / 16; // пункт 6 - 7 - 8: Jump6: ss << y0; MyBigInt Ym(ss.str()); ss.str(""); for (int i = 0; i < rm; i++) { y0 = (19381 * y0 + c) % 65536; ss << y0; Ym.set_value(Ym + static_cast<MyBigInt>(ss.str())); ss.str(""); } ss << y0; Ym.set_value(Ym - static_cast<MyBigInt>(ss.str())); //Ym.set_value(Ym * (static_cast<MyBigInt>("2") ^ "161")); ss.str(""); // пункт 9: stringstream ko; ko << (2 * t) - 1; N.set_value((static_cast<MyBigInt>("2") ^ ko.str())); ss.str(""); ss << 16 << rm; N.set_value(N + ( ((static_cast<MyBigInt>("2") ^ ko.str()) * Ym) )); if (N % static_cast<MyBigInt>("2") == "0") N.set_value(N + "1"); ss.str(""); ko.str(""); // пункт 10: int k = 0; ss << k; // пункт 11: Jump11: MyBigInt Pm((N + ss.str())); ss.str(""); // пункт 12: ss << 2 * t; cout << Pm.get_value() << endl; if (Pm > (static_cast<MyBigInt>("2") ^ ss.str())) { ss.str(""); goto Jump6; } ss.str(""); // пункт 13: ss << k; cout << static_cast<MyBigInt>("2").Gorner((Ps * (N + ss.str())), Pm).get_value() << " " << static_cast<MyBigInt>("2").Gorner((N + ss.str()), Pm).get_value() << " " << Pm.get_value()<< endl; if (static_cast<MyBigInt>("2").Gorner((Ps * (N + ss.str())), Pm) == "1" && static_cast<MyBigInt>("2").Gorner((N + ss.str()), Pm) != "1") { system("pause"); m = m - 1; t = t * 2; // пункт 14: if (m >= 0) { goto Jump5; } else { system("cls"); cout << "Victory bitch!" << endl; system("pause"); } } else { k = k + 2; goto Jump11; } }