mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 12:04:33 +00:00 
			
		
		
		
	update license and if guards
This commit is contained in:
		| @@ -5,7 +5,7 @@ | |||||||
|  |  | ||||||
| // This program is free software: you can redistribute it and/or modify | // This program is free software: you can redistribute it and/or modify | ||||||
| // it under the terms of the GNU General Public License as published by | // it under the terms of the GNU General Public License as published by | ||||||
| // the Free Software Foundation, either version 3 of the License, or | // the Free Software Foundation, either version 2 of the License, or | ||||||
| // (at your option) any later version. | // (at your option) any later version. | ||||||
| // | // | ||||||
| // This program is distributed in the hope that it will be useful, | // This program is distributed in the hope that it will be useful, | ||||||
| @@ -19,7 +19,8 @@ | |||||||
| // Code within namespace sha256 are from Stephan Brumme. | // Code within namespace sha256 are from Stephan Brumme. | ||||||
| // see http://create.stephan-brumme.com/disclaimer.html | // see http://create.stephan-brumme.com/disclaimer.html | ||||||
|  |  | ||||||
| #pragma once | #ifndef RNG_STATE_RNG_STATE_H | ||||||
|  | #define RNG_STATE_RNG_STATE_H | ||||||
|  |  | ||||||
| #include "show.h" | #include "show.h" | ||||||
|  |  | ||||||
| @@ -126,10 +127,9 @@ inline void splitTwoUint32(uint32_t& a, uint32_t& b, const uint64_t x) | |||||||
|   assert(x == patchTwoUint32(a, b)); |   assert(x == patchTwoUint32(a, b)); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void exportRngState(std::vector<uint32_t>& v, const RngState& rs) | inline void exportRngState(uint32_t* v, const RngState& rs) | ||||||
| { | { | ||||||
|   assert(22 == RNG_STATE_NUM_OF_INT32); |   assert(22 == RNG_STATE_NUM_OF_INT32); | ||||||
|   v.resize(RNG_STATE_NUM_OF_INT32); |  | ||||||
|   splitTwoUint32(v[0], v[1], rs.numBytes); |   splitTwoUint32(v[0], v[1], rs.numBytes); | ||||||
|   for (int i = 0; i < 8; ++i) { |   for (int i = 0; i < 8; ++i) { | ||||||
|     v[2 + i] = rs.hash[i]; |     v[2 + i] = rs.hash[i]; | ||||||
| @@ -144,9 +144,8 @@ inline void exportRngState(std::vector<uint32_t>& v, const RngState& rs) | |||||||
|   v[21] = rs.gaussianAvail; |   v[21] = rs.gaussianAvail; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void importRngState(RngState& rs, const std::vector<uint32_t>& v) | inline void importRngState(RngState& rs, const uint32_t* v) | ||||||
| { | { | ||||||
|   assert(RNG_STATE_NUM_OF_INT32 == v.size()); |  | ||||||
|   assert(22 == RNG_STATE_NUM_OF_INT32); |   assert(22 == RNG_STATE_NUM_OF_INT32); | ||||||
|   rs.numBytes = patchTwoUint32(v[0], v[1]); |   rs.numBytes = patchTwoUint32(v[0], v[1]); | ||||||
|   for (int i = 0; i < 8; ++i) { |   for (int i = 0; i < 8; ++i) { | ||||||
| @@ -156,12 +155,24 @@ inline void importRngState(RngState& rs, const std::vector<uint32_t>& v) | |||||||
|   for (int i = 0; i < 3; ++i) { |   for (int i = 0; i < 3; ++i) { | ||||||
|     rs.cache[i] = patchTwoUint32(v[12 + i * 2], v[12 + i * 2 + 1]); |     rs.cache[i] = patchTwoUint32(v[12 + i * 2], v[12 + i * 2 + 1]); | ||||||
|   } |   } | ||||||
|   uint64_t* p = (uint64_t*)&rs.gaussian; |   uint64_t g = patchTwoUint32(v[18], v[19]); | ||||||
|   *p = patchTwoUint32(v[18], v[19]); |   rs.gaussian = reinterpret_cast<double&>(g); | ||||||
|   rs.cacheAvail = v[20]; |   rs.cacheAvail = v[20]; | ||||||
|   rs.gaussianAvail = v[21]; |   rs.gaussianAvail = v[21]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | inline void exportRngState(std::vector<uint32_t>& v, const RngState& rs) | ||||||
|  | { | ||||||
|  |   v.resize(RNG_STATE_NUM_OF_INT32); | ||||||
|  |   exportRngState(v.data(), rs); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline void importRngState(RngState& rs, const std::vector<uint32_t>& v) | ||||||
|  | { | ||||||
|  |   assert(RNG_STATE_NUM_OF_INT32 == v.size()); | ||||||
|  |   importRngState(rs, v.data()); | ||||||
|  | } | ||||||
|  |  | ||||||
| inline std::ostream& operator<<(std::ostream& os, const RngState& rs) | inline std::ostream& operator<<(std::ostream& os, const RngState& rs) | ||||||
| { | { | ||||||
|   std::vector<uint32_t> v(RNG_STATE_NUM_OF_INT32); |   std::vector<uint32_t> v(RNG_STATE_NUM_OF_INT32); | ||||||
| @@ -568,3 +579,5 @@ inline double gRandGen(RngState& rs, const double sigma, const double center) | |||||||
| #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  |  | ||||||
| // This program is free software: you can redistribute it and/or modify | // This program is free software: you can redistribute it and/or modify | ||||||
| // it under the terms of the GNU General Public License as published by | // it under the terms of the GNU General Public License as published by | ||||||
| // the Free Software Foundation, either version 3 of the License, or | // the Free Software Foundation, either version 2 of the License, or | ||||||
| // (at your option) any later version. | // (at your option) any later version. | ||||||
| // | // | ||||||
| // This program is distributed in the hope that it will be useful, | // This program is distributed in the hope that it will be useful, | ||||||
| @@ -16,7 +16,8 @@ | |||||||
| // You should have received a copy of the GNU General Public License | // You should have received a copy of the GNU General Public License | ||||||
| // along with this program.  If not, see <http://www.gnu.org/licenses/>. | // along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| #pragma once | #ifndef RNG_STATE_SHOW_H | ||||||
|  | #define RNG_STATE_SHOW_H | ||||||
|  |  | ||||||
| #include <sstream> | #include <sstream> | ||||||
| #include <string> | #include <string> | ||||||
| @@ -105,12 +106,12 @@ T& reads(T& x, const std::string& str) | |||||||
|   return x; |   return x; | ||||||
| } | } | ||||||
|  |  | ||||||
| void fdisplay(FILE* fp, const std::string& str) | inline void fdisplay(FILE* fp, const std::string& str) | ||||||
| { | { | ||||||
|   fprintf(fp, "%s", str.c_str()); |   fprintf(fp, "%s", str.c_str()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void fdisplayln(FILE* fp, const std::string& str) | inline void fdisplayln(FILE* fp, const std::string& str) | ||||||
| { | { | ||||||
|   fprintf(fp, "%s\n", str.c_str()); |   fprintf(fp, "%s\n", str.c_str()); | ||||||
| } | } | ||||||
| @@ -118,3 +119,5 @@ void fdisplayln(FILE* fp, const std::string& str) | |||||||
| #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  |  | ||||||
| // This program is free software: you can redistribute it and/or modify | // This program is free software: you can redistribute it and/or modify | ||||||
| // it under the terms of the GNU General Public License as published by | // it under the terms of the GNU General Public License as published by | ||||||
| // the Free Software Foundation, either version 3 of the License, or | // the Free Software Foundation, either version 2 of the License, or | ||||||
| // (at your option) any later version. | // (at your option) any later version. | ||||||
| // | // | ||||||
| // This program is distributed in the hope that it will be useful, | // This program is distributed in the hope that it will be useful, | ||||||
| @@ -16,7 +16,8 @@ | |||||||
| // You should have received a copy of the GNU General Public License | // You should have received a copy of the GNU General Public License | ||||||
| // along with this program.  If not, see <http://www.gnu.org/licenses/>. | // along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| #pragma once | #ifndef RNG_STATE_SPRNG_SHA256_H | ||||||
|  | #define RNG_STATE_SPRNG_SHA256_H | ||||||
|  |  | ||||||
| #include "rng-state.h" | #include "rng-state.h" | ||||||
|  |  | ||||||
| @@ -108,3 +109,5 @@ inline bool operator==(const SprngSha256& ss1, const SprngSha256& ss2) | |||||||
| #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | #ifdef CURRENT_DEFAULT_NAMESPACE_NAME | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user