Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 18, 2011 [Issue 6345] New: A different kind of vector operation | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6345 Summary: A different kind of vector operation Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-07-18 12:15:46 PDT --- Currently (DMD 2.054) this is not allowed, but a vector op like this is sometimes useful to me: struct Foo { int x, y; int[100] array; } void main() { auto foos = new Foo[100]; foos[].y += 10; // ******** } For the programmer I think the meaning of such code is easy enough to understand and use. At the moment I don't see the need to define a operator overload for this too (I mean something like opSliceUnary). Don notes: > An interesting use case: > void main() > { > cdouble[100] foos; > foos[].re = 5.0; > } Wilfried Kirschenmann suggests: > void main() { > auto foos = new Foo[100]; > auto ints = new int[100] > ints = foos[].y; > } > > This would simplify the wrinting of numerous application, especially in the writing of image/video processing (eg. rgb2yuv conversions) This would also simplify the writing of template library transforming "array of struct" to "struct of arrays" in a transparent manner for the library user. Andrej Mitrovic notes (I don't understand this): > float[] buffers = malloc..; > float*[] CBuffers = buffers[].ptr; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 18, 2011 [Issue 6345] A different kind of vector operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6345 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm@gmail.com --- Comment #1 from kennytm@gmail.com 2011-07-18 12:44:34 PDT --- What if I define ref int y(Foo[] f) { return f[0].x; } ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 27, 2011 [Issue 6345] A different kind of vector operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6345 --- Comment #2 from bearophile_hugs@eml.cc 2011-07-27 13:56:06 PDT --- Another possible purpose. Given this matrix: auto M = new double[][](10, 20); This: M[][1] = 1.0; Means: foreach (row; p) row[1] = 1.0; This replaces some usages of std.range.transversal(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 28, 2011 [Issue 6345] A different kind of vector operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6345 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-07-28 00:36:12 PDT --- All these operations require the use of strided slices, which would be a huge amount of work to implement. Also, there are a plethora of corner cases. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 28, 2011 [Issue 6345] A different kind of vector operation | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6345 --- Comment #4 from bearophile_hugs@eml.cc 2011-07-28 05:15:59 PDT --- (In reply to comment #3) > All these operations require the use of strided slices, which would be a huge amount of work to implement. Also, there are a plethora of corner cases. I see. Those corner cases are bad. If you think this is too much work for the gain I'll close this enhancement request, to leave similar functionalities to matrix libraries. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation