advise how to encode a matrix in which fields can take one of the values of the set {-1,0,1,2,3,4} (five states in total), I would like to have some function that can encode a matrix of the form:
granit77: Shift into the positive range by 2 units to remove 0 and -1 (followed by restoration after reading) and an integer can easily be formed.
Well, let the set be {0,1,2,3,4,5} - it does not matter, it is important from this group of digits to get an integer, if at this stage I have a 12x6 matrix, you can get something in the form:
seems to fit into int, but I don't know, what if you want matrix 100x6 ;)
SZY: from the Help: Internal representation of int is a long integer of size 4 bytes. Integer constants can take values from -2147483648 to 2147483647. If the constant exceeds the specified range, the result is undefined.
granit77: Well, you still have string variables to spare, although they will be slower. But 0 and -1 must be removed.
Yes! So far there are only string variables - the algorithm itself is still on "paper", I am preparing data for uploading to a file, but then we will need to analyze the data, and that's where speed is needed, while I think how to unload to int instead of stringi
Usually DBMS store group data as a string. The processing speed with large volumes is a pain in the ass. I haven't followed what happened with Clarion, look it up - C compatibility was top-notch there.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
thank you I'm so stupid))))+- gives a minus to go)))))))))
live and learn, live and die a fool))))) works, thanks Alexei for reminding me of the school curriculum...
advise how to encode a matrix in which fields can take one of the values of the set {-1,0,1,2,3,4} (five states in total), I would like to have some function that can encode a matrix of the form:
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
| -1,0,1,2,3,4, -1,0,1,2,3,4 |
save to several integers: int arr[6] = {xxxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx}, with the least amount of computational effort
cps
Show me an example of your matrices.
| 4,4,1,2,1,1, 1,1,1,1,1,1 |
| 4,4,1,2,1,1, 1,1,1,1,1,1 |
| 4,4,4,2,1,1, 1,1,1,1,1,1 |
| 4,3,3,3,3,3, -1,-1,-1,-1,-1,-1 |
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
next:
| 4,4,1,2,2,2, 1,1,1,1,1,1 |
| 4,4,1,2,2,2, 1,1,1,1,1,-1 |
| 3,4,4,2,2,2, 1,1,1,1,1,-1 |
| 4,3,3,3,3,3, 1,1,1,-1,-1,-1 |
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
| 3,3,3,3,3,3, -1,-1,-1,-1,-1,-1|
I want to compactly store data - one line, one integer
Advise how to encode a matrix in which fields can take one of the values of the set {-1,0,1,2,3,4} (five states in total),
Shift into the positive range by 2 units to remove 0 and -1 (followed by restoration after reading) and an integer can easily be formed.
Well, let the set be {0,1,2,3,4,5} - it does not matter, it is important from this group of digits to get an integer, if at this stage I have a 12x6 matrix, you can get something in the form:
| 4,4,1,2,1,1, 1,1,1,1,1,1 | = 2147483647 - 441211111111/2
seems to fit into int, but I don't know, what if you want matrix 100x6 ;)
SZY: from the Help: Internal representation of int is a long integer of size 4 bytes. Integer constants can take values from -2147483648 to 2147483647. If the constant exceeds the specified range, the result is undefined.
Well, you still have string variables to spare, although they will be slower. But 0 and -1 must be removed.
Usually DBMS store group data as a string. The processing speed with large volumes is a pain in the ass. I haven't followed what happened with Clarion, look it up - C compatibility was top-notch there.