|
-
April 11th, 2014, 04:18 AM
#11
Re: Ising Model C++ Metropolis Algorithm
 Originally Posted by D_Drmmr
That's horrible. Why would you advice someone to use a macro for this? A simple text-replace can solve this without obfuscating the code.
@OP Using two different names for the same variable will make your code harder to understand. When you read your code, every time you see 'spin' you need to think "right, that actually just means matrix". If you just use a single name, you'll save yourself a lot of unnecessary thinking, freeing up your brain capacity to understand the code you're writing/debugging/reading/whatever. If spin better describes the values in the matrix, then go ahead and rename your matrix variable to spin (it's a simple search-and-replace). But don't use different names for the same thing unless you want to make your code harder to understand.
I agree - that's why I said in my post #10 that the easiest way would be to do text-replace. I only offered the #define as an option to try to get the code posted by the OP to compile as I suspect that the part of the code using spin() was obtained elsewhere and I not sure of the expertise of the OP based upon the postings.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|