Re: Multiplying transposed matrices in mir

2020-04-19 Thread 9il via Digitalmars-d-learn
On Monday, 20 April 2020 at 02:42:33 UTC, 9il wrote: On Sunday, 19 April 2020 at 20:29:54 UTC, p.shkadzko wrote: On Sunday, 19 April 2020 at 20:06:23 UTC, jmh530 wrote: [...] Thanks. I somehow missed the whole point of "a * a.transposed" not working because "a.transposed" is not allocated.

Re: Multiplying transposed matrices in mir

2020-04-19 Thread 9il via Digitalmars-d-learn
On Sunday, 19 April 2020 at 20:29:54 UTC, p.shkadzko wrote: On Sunday, 19 April 2020 at 20:06:23 UTC, jmh530 wrote: On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote: [...] Ah, you're right. I use it in other places where it hasn't been an issue. I can do it with an allocation

Re: mir: How to change iterator?

2020-04-19 Thread 9il via Digitalmars-d-learn
On Sunday, 19 April 2020 at 22:07:30 UTC, jmh530 wrote: On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote: [snip] /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, Slice!(Iterator, 1, kind)

Re: mir: How to change iterator?

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote: [snip] /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, Slice!(Iterator, 1, kind) y) { import std.stdio : writeln;

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 20:29:54 UTC, p.shkadzko wrote: [snip] Thanks. I somehow missed the whole point of "a * a.transposed" not working because "a.transposed" is not allocated. a.transposed is just a view of the original matrix. Even when I tried to do a raw for loop I ran into issues

Re: How to use import std.algorithm.iteration.permutations?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 April 2020 at 20:25:23 UTC, Basile B. wrote: On Sunday, 19 April 2020 at 17:57:21 UTC, David Zaragoza wrote: [...] `permutation()` returns a lazy range (i.e an iterator). To turn a permutation into a concrete data type use .array on each one. --- void test(int[] array){}

Re: How to use import std.algorithm.iteration.permutations?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:57:21 UTC, David Zaragoza wrote: Hi When I try to build the following: import std.algorithm.iteration; void test(int[] array); void main() { int[] a = [1,1,2,2,3,3]; foreach (p; a.permutations) { test(p); } } I

Re: Multiplying transposed matrices in mir

2020-04-19 Thread p.shkadzko via Digitalmars-d-learn
On Sunday, 19 April 2020 at 20:06:23 UTC, jmh530 wrote: On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote: [snip] well no, "assumeContiguous" reverts the results of the "transposed" and it's "a * a". I would expect it to stay transposed as NumPy does "assert

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote: [snip] well no, "assumeContiguous" reverts the results of the "transposed" and it's "a * a". I would expect it to stay transposed as NumPy does "assert np.all(np.ascontiguous(a.T) == a.T)". Ah, you're right. I use it in other places

Re: Multiplying transposed matrices in mir

2020-04-19 Thread p.shkadzko via Digitalmars-d-learn
On Sunday, 19 April 2020 at 19:13:14 UTC, p.shkadzko wrote: On Sunday, 19 April 2020 at 18:59:00 UTC, jmh530 wrote: On Sunday, 19 April 2020 at 17:55:06 UTC, p.shkadzko wrote: snip So, lubeck mtimes is equivalent to NumPy "a.dot(a.transpose())". There are elementwise operation on two

Re: Multiplying transposed matrices in mir

2020-04-19 Thread p.shkadzko via Digitalmars-d-learn
On Sunday, 19 April 2020 at 18:59:00 UTC, jmh530 wrote: On Sunday, 19 April 2020 at 17:55:06 UTC, p.shkadzko wrote: snip So, lubeck mtimes is equivalent to NumPy "a.dot(a.transpose())". There are elementwise operation on two matrices of the same size and then there is matrix

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:55:06 UTC, p.shkadzko wrote: snip So, lubeck mtimes is equivalent to NumPy "a.dot(a.transpose())". There are elementwise operation on two matrices of the same size and then there is matrix multiplication. Two different things. You had initially said using an

How to use import std.algorithm.iteration.permutations?

2020-04-19 Thread David Zaragoza via Digitalmars-d-learn
Hi When I try to build the following: import std.algorithm.iteration; void test(int[] array); void main() { int[] a = [1,1,2,2,3,3]; foreach (p; a.permutations) { test(p); } } I get the error: .\permutations_example.d(10): Error: function

Re: Multiplying transposed matrices in mir

2020-04-19 Thread p.shkadzko via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:22:12 UTC, jmh530 wrote: On Sunday, 19 April 2020 at 17:07:36 UTC, p.shkadzko wrote: I'd like to calculate XX^T where X is some [m x n] matrix. // create a 3 x 3 matrix Slice!(double*, 2LU) a = [2.1, 1.0, 3.2, 4.5, 2.4, 3.3, 1.5, 0, 2.1].sliced(3, 3); auto b =

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:07:36 UTC, p.shkadzko wrote: I'd like to calculate XX^T where X is some [m x n] matrix. // create a 3 x 3 matrix Slice!(double*, 2LU) a = [2.1, 1.0, 3.2, 4.5, 2.4, 3.3, 1.5, 0, 2.1].sliced(3, 3); auto b = a * a.transposed; // error Looks like it is not possible

Re: Wich: opIndex overloading by return type

2020-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/19/20 11:53 AM, Robert M. Münch wrote: Wouldn't it make a lot of sense to allow different opIndex implementations based on return type? class myC { myT1 opIndex(int x) myT2 opIndex(int x) } Depending on the types involved myC[1] woudl return myT1 or myT2. Use-case: I have a

Multiplying transposed matrices in mir

2020-04-19 Thread p.shkadzko via Digitalmars-d-learn
I'd like to calculate XX^T where X is some [m x n] matrix. // create a 3 x 3 matrix Slice!(double*, 2LU) a = [2.1, 1.0, 3.2, 4.5, 2.4, 3.3, 1.5, 0, 2.1].sliced(3, 3); auto b = a * a.transposed; // error Looks like it is not possible due to "incompatible types for (a) * (transposed(a)):

How to make ddoc/ddox output alias name instead of template

2020-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn
Let's say I'm using TaggedAlgebraic [1] I have a specialized union: union _MTYPE { int val; string sval; } And now I want to use this type everywhere: alias MType = TaggedAlgebraic!_MTYPE; Everywhere in my docs where I have a nice function like: void foo(MType m) It spits out: void

Why Pegged action dont not work in this case ?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
I 've started experimenting Pegged action. Quickly i got blocked by this problem. The start action works where I use the rule but not directly in the rule. Test program: gdb_commander.d: --- /+dub.sdl: dependency "pegged" version="~>0.4.4" versions "dub_run" +/ module gdb_commander; import

Re: Wich: opIndex overloading by return type

2020-04-19 Thread unDEFER via Digitalmars-d-learn
It is easy. You can make both types as children of common parent class myT, and when return myT.

Wich: opIndex overloading by return type

2020-04-19 Thread Robert M. Münch via Digitalmars-d-learn
Wouldn't it make a lot of sense to allow different opIndex implementations based on return type? class myC { myT1 opIndex(int x) myT2 opIndex(int x) } Depending on the types involved myC[1] woudl return myT1 or myT2. Use-case: I have a geomentry object and in one case I get

Re: Can a lib file converted to 1 ob file?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 April 2020 at 11:33:15 UTC, Andre Pany wrote: On Sunday, 19 April 2020 at 10:53:09 UTC, Basile B. wrote: On Sunday, 19 April 2020 at 10:48:04 UTC, Basile B. wrote: This should work if you pass the static library files to the linker. It is exactly its job to select what's used

Re: Can a lib file converted to 1 ob file?

2020-04-19 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 19 April 2020 at 10:53:09 UTC, Basile B. wrote: On Sunday, 19 April 2020 at 10:48:04 UTC, Basile B. wrote: This should work if you pass the static library files to the linker. It is exactly its job to select what's used from the archive. So you would have to pass your stuff and

Re: Can a lib file converted to 1 ob file?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 April 2020 at 10:48:04 UTC, Basile B. wrote: This should work if you pass the static library files to the linker. It is exactly its job to select what's used from the archive. So you would have to pass your stuff and optionally phobos2 as a static library (but this would also

Re: Can a lib file converted to 1 ob file?

2020-04-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 April 2020 at 07:50:13 UTC, Andre Pany wrote: Hi, My understanding is, a lib file is a collection of multiple obj files. This is exact. From a delphi app I want to call D coding without using a dll. Delphi does not know the concept of lib files but can link obj files.

Can a lib file converted to 1 ob file?

2020-04-19 Thread Andre Pany via Digitalmars-d-learn
Hi, My understanding is, a lib file is a collection of multiple obj files. From a delphi app I want to call D coding without using a dll. Delphi does not know the concept of lib files but can link obj files. Linking all single obj files of DRuntime, phobos and my library might be