ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
Last change
on this file since b1672e1 was 4328016, checked in by Thierry Delisle <tdelisle@…>, 9 years ago |
Starting ground work on N-dimension array proof of concept
|
-
Property mode
set to
100644
|
File size:
487 bytes
|
Rev | Line | |
---|
[4328016] | 1 | #include <fstream>
|
---|
| 2 |
|
---|
| 3 | // [unsigned, unsigned] offset_to_index(unsigned offset, unsigned sx, unsigned sy)
|
---|
| 4 | // {
|
---|
| 5 | // return [offset / sx, offset % sy];
|
---|
| 6 | // }
|
---|
| 7 |
|
---|
| 8 | forall(otype index_t)
|
---|
| 9 | index_t offset_to_index(unsigned offset, index_t size)
|
---|
| 10 | {
|
---|
| 11 | return [offset / size.0, offset % size.1];
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | int main(int argc, char* argv[])
|
---|
| 15 | {
|
---|
| 16 | unsigned x = 0, y = 0, i = 0;
|
---|
| 17 | unsigned sx = 4, sy = 4;
|
---|
| 18 |
|
---|
| 19 | i = 6;
|
---|
| 20 | [x, y] = offset_to_index(6, [sx, sy]);
|
---|
| 21 |
|
---|
| 22 | sout | x | ' ' | y | endl;
|
---|
| 23 |
|
---|
| 24 | return 0;
|
---|
| 25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.