Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Ali Çehreli via Digitalmars-d-learn
On 12/22/20 10:53 AM, Rekel wrote:> On Tuesday, 22 December 2020 at 16:56:18 UTC, Ali Çehreli wrote: >> >[4]Foo b; /* an array of four Foos */ >> >> [4] already has a meaning. ;) > > It does in that context? Do tell, I'm unaware. An array literal with a single int element 4: pragma(msg,

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Rekel via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 16:55:40 UTC, Mike Parker wrote: On Tuesday, 22 December 2020 at 15:31:06 UTC, Rekel wrote: Don't take that as a defence of changing pointer syntax by the way, just noting I think the argument pointers and arrays should be defined using a similar syntax is

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Rekel via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 16:56:18 UTC, Ali Çehreli wrote: >[4]Foo b; /* an array of four Foos */ [4] already has a meaning. ;) It does in that context? Do tell, I'm unaware. Also, is it possible to move entire thread to a different forum group?  This feels more like a

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread ag0aep6g via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 16:56:18 UTC, Ali Çehreli wrote: On 12/22/20 6:35 AM, ag0aep6g wrote: > Flip the pointer syntax, too: > > *Foo a; /* a pointer to a Foo */ I am not a language expert but I think that would make D's parsing complicated (like C++'s < token) because * already

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Ali Çehreli via Digitalmars-d-learn
On 12/22/20 8:56 AM, Ali Çehreli wrote: > * already means "derefence" "dereference" > > But now we're no longer C-like, I guess.x That x seems to be due to my fat Emacs fingers. Ali

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Ali Çehreli via Digitalmars-d-learn
On 12/22/20 6:35 AM, ag0aep6g wrote: > Flip the pointer syntax, too: > > *Foo a; /* a pointer to a Foo */ I am not a language expert but I think that would make D's parsing complicated (like C++'s < token) because * already means "derefence" in that position. So, the parser would see

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 15:31:06 UTC, Rekel wrote: Don't take that as a defence of changing pointer syntax by the way, just noting I think the argument pointers and arrays should be defined using a similar syntax is not consistent when thinking about indexing & dereferencing.

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Rekel via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 15:24:04 UTC, Rekel wrote: The way C syntax handles pointers isn't very consistent to begin with imo. It's strange & and * are prepended to pointer variables for example, while indexing is postpended. Leads to stuff like; (*array_of_pointers_to_arrays[2])[1] vs

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Rekel via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 14:15:12 UTC, Mike Parker wrote: [][4]Foo is completely backwards from and inconsistent with the pointer declaration syntax. We shouldn't want to intentionally introduce inconsistencies. The way C syntax handles pointers isn't very consistent to begin with

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread ag0aep6g via Digitalmars-d-learn
On 22.12.20 15:15, Mike Parker wrote: On Tuesday, 22 December 2020 at 13:59:54 UTC, Rekel wrote: I am curious by the way, what do you think of the [][4]Row suggestion I gave? In a way you'd have your  & could eat it too, i think ^^ (Still a strange saying to me) Currently, D's variable

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 13:59:54 UTC, Rekel wrote: I am curious by the way, what do you think of the [][4]Row suggestion I gave? In a way you'd have your  & could eat it too, i think ^^ (Still a strange saying to me) Currently, D's variable declaration syntax is consistent and,

Re: Trying to understand multidimensional arrays in D

2020-12-22 Thread Rekel via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 07:19:49 UTC, Ali Çehreli wrote: Let me try the history example: Row[4][] history; Row array (of 4) array. Fully disagreed: D's array syntax makes me happy; designed right. :) I think i see your point, strange how a change of words makes some things

Re: Trying to understand multidimensional arrays in D

2020-12-21 Thread Ali Çehreli via Digitalmars-d-learn
: "int pointer pointer". :) > Feel free to read them the way you want, but personally, I read int* foo > as 'integer pointer', which is not 'outward'. Thank you! Me too! :) Let me try the history example: Row[4][] history; Row array (of 4) array. > just noticed this is how D

Re: Trying to understand multidimensional arrays in D

2020-12-21 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 22, 2020 at 04:47:13AM +, Rekel via Digitalmars-d-learn wrote: [...] > Defending array-notation by giving an example of explicitly not using > declared aliases makes no sense to me. > When I define 2d arrays, or index them, I think in row -> column terms > (often math notation for

Re: Trying to understand multidimensional arrays in D

2020-12-21 Thread Rekel via Digitalmars-d-learn
Small addition, not out of jest; If plug and play consistency given aliases is required (which seems pointless, as they exit to be used), the best solution, which would avoid indexing inconsistency given regular reading order, would be the following; alias Row = [3]int; [1][2][3]int history;

Re: Trying to understand multidimensional arrays in D

2020-12-21 Thread Rekel via Digitalmars-d-learn
this thread is 3 years old by the way, sorry for that, just noticed this is how D handles multidimensional arrays (I may add a note about this to the tour suggestions). It saddens me quite a bit, as I see it as a big design flaw and quite a turn-off, "unfortunately one that can't be

Re: Blog post about multidimensional arrays in D

2020-03-30 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 27 March 2020 at 14:18:13 UTC, p.shkadzko wrote: I agree. I was planning to do several follow-ups after this first brief overview. For example, looks like just one "byDim" requires a separate post. The goal was just to show ppl who know nothing or a little about D and Mir that Mir

Re: Blog post about multidimensional arrays in D

2020-03-27 Thread p.shkadzko via Digitalmars-d-learn
On Friday, 27 March 2020 at 13:10:00 UTC, jmh530 wrote: On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic

Re: Blog post about multidimensional arrays in D

2020-03-27 Thread p.shkadzko via Digitalmars-d-learn
On Friday, 27 March 2020 at 11:19:06 UTC, WebFreak001 wrote: On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: [...] I don't really know mir myself, but for the start of the content: [...] Ok, looks like I need to reread the slices topic. It always confused me especially when

Re: Blog post about multidimensional arrays in D

2020-03-27 Thread jmh530 via Digitalmars-d-learn
On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file

Re: Blog post about multidimensional arrays in D

2020-03-27 Thread WebFreak001 via Digitalmars-d-learn
On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file

Blog post about multidimensional arrays in D

2020-03-27 Thread p.shkadzko via Digitalmars-d-learn
I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with snippets for personal use but then kind of escalated

Re: Trying to understand multidimensional arrays in D

2017-01-29 Thread Ali Çehreli via Digitalmars-d-learn
On 01/25/2017 05:47 PM, Profile Anaysis wrote: > a 4x4 matrix and have a history of it. Just > n 4x4 matrices but each matrix is a fixed size but there can be an > arbitrary(dynamic) number. I don't think using aliases is recommended yet. It can simplify things a lot: import std.stdio;

Re: Trying to understand multidimensional arrays in D

2017-01-26 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 January 2017 at 05:20:07 UTC, Profile Anaysis wrote: (On the contrary, declarations in C or C++ looks rather unintuitive from this perspective: `T a[4][5][6]` is means that `a` is an array of 4 arrays of 5 arrays of 6 arrays of `T`. Note how we have to read left-to-right but

Re: Trying to understand multidimensional arrays in D

2017-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 26, 2017 05:44:04 Profile Anaysis via Digitalmars-d- learn wrote: > I am using static arrays because the size of the matrix is fixed. > I need to allocate them though because that is what my > matrix_history contains. If I understood correctly, you want a dynamic array of

Re: Trying to understand multidimensional arrays in D

2017-01-26 Thread Mike Parker via Digitalmars-d-learn
Sorry. I mistyped some of my examples. Obviously dropped some news: auto a = new int[](4); auto b = new int[][](4); And the static arrays should be: int[4] c; int[][4] d; And I would also like managed to overlook there is no static array in sight here: auto y = new int[1][2][][](3,4); The

Re: Trying to understand multidimensional arrays in D

2017-01-26 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 26 January 2017 at 05:50:03 UTC, Profile Anaysis wrote: It is inconsistent with dynamic arrays and mixing them creates a mess in the order of indices. I best someone was asleep at the wheel when programming the code for static arrays. (probably someone different than who

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Profile Anaysis via Digitalmars-d-learn
On Thursday, 26 January 2017 at 03:02:32 UTC, Jonathan M Davis wrote: On Thursday, January 26, 2017 01:47:53 Profile Anaysis via Digitalmars-d- learn wrote: [...] Like in C/C++, types are mostly read outward from the variable name in D. In both C/C++ and D, [...] Actually, I think

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Profile Anaysis via Digitalmars-d-learn
On Thursday, 26 January 2017 at 03:02:32 UTC, Jonathan M Davis wrote: On Thursday, January 26, 2017 01:47:53 Profile Anaysis via Digitalmars-d- learn wrote: [...] Like in C/C++, types are mostly read outward from the variable name in D. In both C/C++ and D, [...] Thanks. I'll just

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Profile Anaysis via Digitalmars-d-learn
On Thursday, 26 January 2017 at 02:29:07 UTC, Ivan Kazmenko wrote: On Thursday, 26 January 2017 at 01:47:53 UTC, Profile Anaysis wrote: does this mean that have int[][4][4] matrix_history; backwards? int[4][4][] matrix_history; this creates even a more set of problems. In short,

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 26, 2017 01:47:53 Profile Anaysis via Digitalmars-d- learn wrote: > I'm a bit confused by how D does arrays. > > I would like to create a array of matrices but I do not seem to > get the correct behavior: > > int[][4][4] matrix_history; Like in C/C++, types are mostly

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 January 2017 at 01:47:53 UTC, Profile Anaysis wrote: does this mean that have int[][4][4] matrix_history; backwards? int[4][4][] matrix_history; this creates even a more set of problems. In short, you are right, `int[4][4][]` is a dynamic array of `int[4][4]`. In

Trying to understand multidimensional arrays in D

2017-01-25 Thread Profile Anaysis via Digitalmars-d-learn
method doesn't seem to. If I do auto x = matrix_history[0]; x is not a int[4][4] but of type int[4](as reported by the debugger), which is very confusing. it seems that the way D indexes multidimensional arrays is not logical nor consistent from my perspective. auto x = matrix_history[0

Re: Rectangular multidimensional arrays for D

2015-01-14 Thread jmh530 via Digitalmars-d
It might make sense to take a look at Armadillo (another C++ linear algebra library) for inspiration on multidimensional arrays.

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread Laeeth Isharc via Digitalmars-d
On Friday, 11 October 2013 at 22:41:06 UTC, H. S. Teoh wrote: What's the reason Kenji's pull isn't merged yet? As I see it, it does not introduce any problematic areas, but streamlines multidimensional indexing notation in a nice way that fits in well with the rest of the language. I, for

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread aldanor via Digitalmars-d
A gap in multi-dimensional rectangular arrays functionality in D is sure a huge blocker when trying to use it for data science tasks. Wonder what's the general consensus on this?

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread H. S. Teoh via Digitalmars-d
On Mon, Dec 22, 2014 at 11:35:17AM +, aldanor via Digitalmars-d wrote: A gap in multi-dimensional rectangular arrays functionality in D is sure a huge blocker when trying to use it for data science tasks. Wonder what's the general consensus on this? Kenji's PR has been merged in the

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread H. S. Teoh via Digitalmars-d
On Mon, Dec 22, 2014 at 08:49:45AM +, Laeeth Isharc via Digitalmars-d wrote: On Friday, 11 October 2013 at 22:41:06 UTC, H. S. Teoh wrote: What's the reason Kenji's pull isn't merged yet? As I see it, it does not introduce any problematic areas, but streamlines multidimensional indexing

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread aldanor via Digitalmars-d
On Monday, 22 December 2014 at 22:36:16 UTC, H. S. Teoh via Digitalmars-d wrote: FYI, Kenji's merge has since been merged. So now the stage is set for somebody to step up and write a nice multidimensional array implementation. One important thing to wish for, in my opinion, is that the

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread Laeeth Isharc via Digitalmars-d
On Monday, 22 December 2014 at 22:46:57 UTC, aldanor wrote: On Monday, 22 December 2014 at 22:36:16 UTC, H. S. Teoh via Digitalmars-d wrote: FYI, Kenji's merge has since been merged. So now the stage is set for somebody to step up and write a nice multidimensional array implementation. One

Re: Rectangular multidimensional arrays for D

2014-12-22 Thread uri via Digitalmars-d
On Tuesday, 23 December 2014 at 03:11:20 UTC, Laeeth Isharc wrote: On Monday, 22 December 2014 at 22:46:57 UTC, aldanor wrote: On Monday, 22 December 2014 at 22:36:16 UTC, H. S. Teoh via Digitalmars-d wrote: FYI, Kenji's merge has since been merged. So now the stage is set for somebody to

Re: Rectangular multidimensional arrays for D

2013-10-14 Thread ilya-stromberg
On Tuesday, 8 October 2013 at 14:41:47 UTC, Denis Shelomovskij wrote: I accidentally discovered Andrei wrote [1] multidimensional array implementation is needed. If it really is, I will work to revise the API and prepare my implementation [2] for review if nobody is doing it already. Also as

Re: Rectangular multidimensional arrays for D

2013-10-11 Thread H. S. Teoh
On Tue, Oct 08, 2013 at 06:42:12PM +0400, Denis Shelomovskij wrote: I accidentally discovered Andrei wrote [1] multidimensional array implementation is needed. If it really is, I will work to revise the API and prepare my implementation [2] for review if nobody is doing it already. Also as

Re: Rectangular multidimensional arrays for D

2013-10-09 Thread Denis Shelomovskij
09.10.2013 7:55, Nick B пишет: On Tuesday, 8 October 2013 at 17:26:46 UTC, Stefan Frijters wrote: andrei wrote: I too are interesteed in this area as well. Dennis do you only plan to focus on multidimensional arrays only, or will you incorporate the above matrices as well ?? What features are

Re: Rectangular multidimensional arrays for D

2013-10-09 Thread Stefan Frijters
On Wednesday, 9 October 2013 at 08:30:11 UTC, Denis Shelomovskij wrote: 09.10.2013 7:55, Nick B пишет: On Tuesday, 8 October 2013 at 17:26:46 UTC, Stefan Frijters wrote: andrei wrote: I too are interesteed in this area as well. Dennis do you only plan to focus on multidimensional arrays

Rectangular multidimensional arrays for D

2013-10-08 Thread Denis Shelomovskij
...@digitalmars.com https://github.com/D-Programming-Language/dmd/pull/443 * October 25, 2011: Original Multidimensional arrays for D post. No response from Phobos developers. http://forum.dlang.org/thread/j864es$2gi0$1...@digitalmars.com * June 17, 2012: A request for template that can

Re: Rectangular multidimensional arrays for D

2013-10-08 Thread Stefan Frijters
still isn't merged. http://forum.dlang.org/thread/j6sp68$2a7k$1...@digitalmars.com https://github.com/D-Programming-Language/dmd/pull/443 * October 25, 2011: Original Multidimensional arrays for D post. No response from Phobos developers. http://forum.dlang.org/thread/j864es$2gi0$1

Re: Rectangular multidimensional arrays for D

2013-10-08 Thread Nick B
On Tuesday, 8 October 2013 at 17:26:46 UTC, Stefan Frijters wrote: andrei wrote: * We need to have a battery of multidimensional array shapes along with simple iteration and access primitives, at least for interfacing with scientific libraries that define and expect such formats. I'm thinking

Re: Multidimensional arrays for D

2012-12-03 Thread Denis Shelomovskij
29.11.2012 15:59, John Colvin пишет: On Tuesday, 25 October 2011 at 10:53:16 UTC, Denis Shelomovskij wrote: Sources will be at GitHub as soon as I am asked for it. I'm asking :) Sorry for the delay. You are welcome! And it is already there. You need unstd.multidimensionalarray from

Re: Multidimensional arrays for D

2012-11-29 Thread John Colvin
On Tuesday, 25 October 2011 at 10:53:16 UTC, Denis Shelomovskij wrote: Sources will be at GitHub as soon as I am asked for it. I'm asking :)

Re: Multidimensional arrays for D

2012-11-29 Thread deed
Documentation and sources: http://deoma-cmd.ru/d/docs/src/my/rarray.html In RectangularArray there's an alias named dimention, which probably should be dimension.

Re: Multidimensional arrays for D

2011-11-02 Thread Marco Leise
This looks nice. I like how much is possible with the foreach delegates. For the most part when I need a matrix, it is for 2D rotation and translation or OpenGL. It would be nice if one day OpenGL bindings would have overloads that accept your matrices. The row/coumn order is different

Re: Multidimensional arrays for D

2011-10-26 Thread Norbert Nemec
Excellent! I have toying around with similar ideas for years. Never found the time to really get into it. :-( Some ideas below inline. On 25.10.2011 13:52, Denis Shelomovskij wrote: What does D already have: build-in rectangular static arrays, dynamic arrays of arrays,

Multidimensional arrays for D

2011-10-25 Thread Denis Shelomovskij
What does D already have: build-in rectangular static arrays, dynamic arrays of arrays, std.range.frontTransversal, std.range.transversal. Some time ago I was told that FORTRAN is good for its arrays and heard me saying it is easy to implement in C++ or D, but in D it will have more

Re: Multidimensional arrays for D

2011-10-25 Thread Zardoz
On Tue, 25 Oct 2011 14:52:04 +0300, Denis Shelomovskij wrote: Looks interesting. This summer I did a small lib around vectors and matrices, at same time that I was learning D. Perhaps you can borrow some idea or not. It's focused for using it with OpenGL so they are limited to squared