digitalmars.D.learn - understanding mir, generic nd array iterator
- monkyyy (15/16) Sep 10 got links to mir, docs I can barely read (srsly math language is
- monkyyy (46/62) Sep 14 Will need to gentricify this, but this seems promising
- Dejan Lekic (2/6) Sep 15 I can barely read your posts, yet I do not complain...
- monkyyy (2/9) Sep 15 you havnt? You sure?
- Andy Valencia (6/16) Sep 15 Not going to lie, I had no idea what "mir" meant, nor what an "nd
- monkyyy (5/24) Sep 15 mir is a lib that has nd math; that allot of people know is meta
- Andy Valencia (3/8) Sep 15 Cool... thanks. A world I never even knew existed!
- jmh530 (6/7) Sep 17 Documentation for mir iterators is here:
I askeddoes a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension) ndslice allocates, so, hottake misnamed. A slice is a reference to an array, a dynmaic array is a gc allocated array https://opendlang.org/library/mir.ndslice.allocation.slice.4.html#Slice Found `field`, says its a something defined by an opIndex, better, but no nd `fieldnd.d`or something exists but it defines 2 types of nd fields and not a generic mapping, idk `FieldIterator` exists but its opSlice only takes 2 arguments so I think I can rule it out as nd etc. So I dont think it exists in this tangled mess? Maybe, idk? I think in its naming scheme it would be called an ndfield
Sep 10
On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:I askedWill need to gentricify this, but this seems promising ```d import std; struct Tuple(T...){ enum istuple=true; T expand; alias expand this; } auto tuple(T...)(T args){ return Tuple!T(args); } unittest{ auto foo=tuple(1,"hi"); assert(foo[0]==1); assert(foo[1]=="hi"); auto bar=tuple(); } enum istuple(T)=is(typeof(T.istuple)); unittest{ assert(istuple!(typeof(tuple(1,2)))==true); assert(istuple!int==false); } auto iterate(T,S)(T t,S s){ struct foreach_{ int opApply(int delegate(int,int) dg){ int result; static foreach(TI;0..t.length){ foreach(x;t[TI]){ static foreach(SI;0..s.length){ foreach(y;s[SI]){ result=dg(x,y); if(result>2){return result;} if(result==1){break;} }} }} return result; }} return foreach_(); } unittest{ loop:foreach(x,y;iterate(tuple(iota(0,3),iota(6,9)),tuple(iota(4,6)))){ writeln(x,',',y); if(x==6){break;} if(x==7){break loop;} }} ```does a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension) ndslice allocates, so, hottake misnamed. A slice is a reference to an array, a dynmaic array is a gc allocated array https://opendlang.org/library/mir.ndslice.allocation.slice.4.html#Slice Found `field`, says its a something defined by an opIndex, better, but no nd `fieldnd.d`or something exists but it defines 2 types of nd fields and not a generic mapping, idk `FieldIterator` exists but its opSlice only takes 2 arguments so I think I can rule it out as nd etc. So I dont think it exists in this tangled mess? Maybe, idk? I think in its naming scheme it would be called an ndfield
Sep 14
On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:I askedI can barely read your posts, yet I do not complain...does a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension)
Sep 15
On Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:you havnt? You sure?I askedI can barely read your posts, yet I do not complain...does a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension)
Sep 15
On Monday, 15 September 2025 at 17:07:36 UTC, monkyyy wrote:On Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:Not going to lie, I had no idea what "mir" meant, nor what an "nd array" is. For such things I mostly wait and see if I can pick up my answers from the context of any responses. Mostly! :-) AndyOn Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:you havnt? You sure?I askedI can barely read your posts, yet I do not complain...does a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension)
Sep 15
On Monday, 15 September 2025 at 20:10:22 UTC, Andy Valencia wrote:On Monday, 15 September 2025 at 17:07:36 UTC, monkyyy wrote:mir is a lib that has nd math; that allot of people know is meta programming to hell and back but no one can tell ya how to use it nd is "N" as anonymous int and D as in dimension, 2d vs 3d vs ... 99dOn Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:Not going to lie, I had no idea what "mir" meant, nor what an "nd array" is. For such things I mostly wait and see if I can pick up my answers from the context of any responses. Mostly! :-) AndyOn Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:you havnt? You sure?I askedI can barely read your posts, yet I do not complain...does a preexisting nd array iterator exist?got links to mir, docs I can barely read (srsly math language is anticomprehension)
Sep 15
On Monday, 15 September 2025 at 20:23:23 UTC, monkyyy wrote:mir is a lib that has nd math; that allot of people know is meta programming to hell and back but no one can tell ya how to use it nd is "N" as anonymous int and D as in dimension, 2d vs 3d vs ... 99dCool... thanks. A world I never even knew existed! Andy
Sep 15
On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:[snip]Documentation for mir iterators is here: http://mir-algorithm.libmir.org/mir_ndslice_iterator.html If you want to use mir without using the GC. You can allocate with malloc, custom allocator, or use an RC allocator. http://mir-algorithm.libmir.org/mir_ndslice_allocation.html
Sep 17
On Wednesday, 17 September 2025 at 12:06:32 UTC, jmh530 wrote:On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:I see nd-iota but it seems under powered(handling only the single argument case of iota) I could spell that `auto fixediota(I)(I start,I end)=>iota(end-start).map!(a=>a+start)` to get the 2 argument version (3 arguments could be a little tricky) soooo ```d fixedndiota(???)=>... ndfield(???)=>fixediota(???).map!(a=>foo.opIndex(a)); ``` That doesnt seem premade anymore[snip]Documentation for mir iterators is here: http://mir-algorithm.libmir.org/mir_ndslice_iterator.htmlIf you want to use mir without using the GC. You can allocate with malloc, custom allocator, or use an RC allocator. http://mir-algorithm.libmir.org/mir_ndslice_allocation.htmlNot about allocating, user defined opIndex on user defined data If mir only defines a single data-type-family and is deeply opinionated about controlling it(which seems to be increasingly the case) its not generic and leaving some level of simplicity on the table.
Sep 17
On Wednesday, 17 September 2025 at 14:57:19 UTC, monkyyy wrote:[snip]Sorry, I'm having trouble understanding what you're trying to do.
Sep 17
On Wednesday, 17 September 2025 at 19:02:22 UTC, jmh530 wrote:On Wednesday, 17 September 2025 at 14:57:19 UTC, monkyyy wrote:I was hoping this code already existed https://gist.github.com/crazymonkyyy/bb6c52dd08ffb55b8e38b3f66896f459[snip]Sorry, I'm having trouble understanding what you're trying to do.
Sep 25









monkyyy <crazymonkyyy gmail.com> 