Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Request for source code review of simple Ising model
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Udyant Wig, post: 5155067"] | void initialize_bitsource (int16_t *bitsource) | { | int i; | int int_count = minimum_multiple_16 (dimension * dimension); | | for (i = 0; i < int_count; i++) { | *bitsource = (int16_t)(rand () % RAND_MAX); | } | } Note that this code does not work as would be expected (it keeps setting the same integer.) Either add bitsource++; to the loop body, or use this rewrite (using the loop form suggested by Ben Bacarisse): void initialize_bitsource (int16_t *bitsource) { int int_count = minimum_multiple_16 (dimension * dimension); int16_t *ip = bitsource, *end = ip + int_count * sizeof *ip; while (ip < end) { *ip = (int16_t)(rand () % RAND_MAX); ip++; } } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Request for source code review of simple Ising model
Top