Re: Improving dot product for standard multidimensional D arrays

2020-03-03 Thread maarten van damme via Digitalmars-d-learn
it is difficult to write an efficient matrix matrix multiplication in any
language. If you want a fair comparison, implement your naive method in
python and compare those timings.

Op di 3 mrt. 2020 om 04:20 schreef 9il via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com>:

> On Sunday, 1 March 2020 at 20:58:42 UTC, p.shkadzko wrote:
> > Hello again,
> >
> > Thanks to previous thread on multidimensional arrays, I managed
> > to play around with pure D matrix representations and even
> > benchmark a little against numpy:
> >
> > [...]
>
> Matrix multiplication is about cache-friendly blocking.
> https://www.cs.utexas.edu/users/pingali/CS378/2008sp/papers/gotoPaper.pdf
>
> `mir-blas` package can be used for matrix operations for ndslice.
>   `cblas`  - if you want to work with your own matrix type .
>


Re: D is Multiplatform[DUVIDA]

2017-09-08 Thread maarten van damme via Digitalmars-d-learn
It's a compiled language, it'll behave like c++.

2017-09-08 7:13 GMT+02:00 dark777 via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com>:

> On Friday, 8 September 2017 at 03:56:25 UTC, rikki cattermole wrote:
>
>> On 08/09/2017 3:08 AM, dark777 wrote:
>>
>>> On Friday, 8 September 2017 at 00:09:08 UTC, solidstate1991 wrote:
>>>
 On Thursday, 7 September 2017 at 23:58:05 UTC, dark777 wrote:

> Good night, did you want to know this? Is the DE language
> cross-platform or cross-compile like C ++?
>

 GDC and LDC has multi-platform support, I'm currently working on an ARM
 backend for DMD.

>>>
>>> so does it mean that if I develop a program using the D language in BSD
>>> creating generic resources for example and compiling on windows, linux and
>>> darwin it would work fine?
>>>
>>
>> Each platform has its own unique behavior and related code.
>> Gotta try it to know for certain.
>>
>> But that is unrelated to D in the most part :)
>>
>
> but in any case then the D language can be considered multiplatform?
>


Re: very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
zeroMemory(, scd.sizeof);

void zeroMemory(void* ad,size_t size){
(cast(byte*)& ad)[0 .. size] = 0;
}


I was totally corrupting my stack and it's not even needed in D, the
compiler zero's it out automatically.
Mystery solved, thanks a lot irc (adam,wolfgang,...)


2017-08-24 17:26 GMT+02:00 maarten van damme :

> I should probably add that the error is a hresult, being 0 when it works
> but -2005270527 when it fails.
>
> 2017-08-24 17:24 GMT+02:00 maarten van damme :
>
>> Hi all.
>>
>> This works (dub --arch=x86_mscoff) http://dpaste.com/1XCJEX7 but this
>> fails : http://dpaste.com/1C7WMB7 .
>>
>> Notice that all I've done is manually inlined init3d...
>>
>> You can compile this with the following dub.json
>>
>> http://dpaste.com/2QBQFSX
>>
>> Any help would be appreciated, it make absolutely no sense to me.
>>
>
>


Re: very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
I should probably add that the error is a hresult, being 0 when it works
but -2005270527 when it fails.

2017-08-24 17:24 GMT+02:00 maarten van damme :

> Hi all.
>
> This works (dub --arch=x86_mscoff) http://dpaste.com/1XCJEX7 but this
> fails : http://dpaste.com/1C7WMB7 .
>
> Notice that all I've done is manually inlined init3d...
>
> You can compile this with the following dub.json
>
> http://dpaste.com/2QBQFSX
>
> Any help would be appreciated, it make absolutely no sense to me.
>


very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
Hi all.

This works (dub --arch=x86_mscoff) http://dpaste.com/1XCJEX7 but this fails
: http://dpaste.com/1C7WMB7 .

Notice that all I've done is manually inlined init3d...

You can compile this with the following dub.json

http://dpaste.com/2QBQFSX

Any help would be appreciated, it make absolutely no sense to me.


Re: How to get uniq to return an array?

2017-07-04 Thread maarten van damme via Digitalmars-d-learn
have you tried std.range's .array?

2017-07-04 13:00 GMT+02:00 PumpkinCake via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com>:

> I'm trying to strip repeated values out of an int array using uniq. It's
> returning a UniqResult which can't be accessed like an array... how can I
> get it to return an array, or cast whatever it is returning to be an array?
>


Re: Neural Networks / ML Libraries for D

2016-10-25 Thread maarten van damme via Digitalmars-d-learn
There is mir https://github.com/libmir/mir which is geared towards machine
learning, I don't know if it has anything about neural networks, I've yet
to use it. If you're only interested in neural networks, I've used FANN (a
C library) together with D and it worked very well.

2016-10-25 13:17 GMT+02:00 Saurabh Das via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com>:

> Hello,
>
> Are there any good ML libraries for D? In particular, looking for a neural
> network library currently. Any leads would be appreciated.
>
> Thanks,
> Saurabh
>
>


Re: store template value

2015-08-02 Thread maarten van damme via Digitalmars-d-learn
Oh, neat. This saves the day :)

2015-08-01 23:22 GMT+02:00 Ali Çehreli digitalmars-d-learn@puremagic.com:

 On 08/01/2015 08:37 AM, maarten van damme via Digitalmars-d-learn wrote:

 I have a class that creates a task in it's constructor. How do I store
 this
 created task as one of it's value members and later on call .yieldForce()?


 Tasks can be created with a function pointer 'function parameter' as well.
 (This has already been added to Programming in D but it is not available
 on the web site yet.)

 I learned the exact type by the help of pragma(msg) below and used it to
 create MyTask and myTasks:

 import std.parallelism;

 double foo(int i)
 {
 return i * 1.5;
 }

 double bar(int i)
 {
 return i * 2.5;
 }

 void main()
 {
 auto tasks = [ task(foo, 1),
task(bar, 2) ];// ← compiles

 pragma(msg, typeof(tasks[0]));

 alias MyTask = Task!(run, double function(int), int)*;

 MyTask[] myTasks;
 myTasks ~= task(foo, 1);
 myTasks ~= task(bar, 2);
 }

 Ali




store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
I have a class that creates a task in it's constructor. How do I store this
created task as one of it's value members and later on call .yieldForce()?


Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
But it's std.parallelism's task...
And how can I use get!T if I don't know the type of the task?

2015-08-01 19:02 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 On Saturday, 1 August 2015 at 16:41:54 UTC, maarten van damme wrote:

 I was afraid I would have to do that. Templatizing the class on the value
 doesn't work as I later on want to create a hashmap of these classes. When
 I assign a task to a variant, how do I call .yieldForce later on?



 You can get a type from a Variant with the get!T method then call it.

 But actually, maybe Task should just be an interface with the yieldForce
 method then you create classes that implement it and pass them to the
 constructor. Then there's no need for templates or casting at all.



Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
I was afraid I would have to do that. Templatizing the class on the value
doesn't work as I later on want to create a hashmap of these classes.
When I assign a task to a variant, how do I call .yieldForce later on?

2015-08-01 18:28 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 On Saturday, 1 August 2015 at 15:37:46 UTC, maarten van damme wrote:

 I have a class that creates a task in it's constructor. How do I store
 this created task as one of it's value members and later on call
 .yieldForce()?


 If the class itself isn't templated on the type, you'll want to use
 something like std.variant.Variant to store it.



Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
You can certainly use thread but in most use cases, concurrency or
parallelism will accomplish the same in a much saner/safer way. (they're
wrappers around core.thread anyway).
Don't know of any tutorials about core.thread, about the other two you can
find help here : http://ddili.org/ders/d.en/

2015-07-16 11:24 GMT+02:00 aki via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 On Thursday, 16 July 2015 at 08:21:26 UTC, maarten van damme wrote:

 Have you checked out std.parallelism and std.concurrency?


 I know std.concurrency to use spawn. If I cannot use Thread,
 I'll implement by spawn. But want to try Thread class because
 it seems similar to Java's Thread class.
 I don't know std.parallelism. It seems for the different case.

 Aki.




Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
Have you checked out std.parallelism and std.concurrency?

2015-07-16 9:57 GMT+02:00 aki via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 I can't resolve the compile errors:

 import core.thread;
 class DerivedThread : Thread {
 int count = 0;
 this() {
 super(run);
 }
 private void run() {
 inc();  //testThread.d(8): Error: shared method
 testThread.DerivedThread.inc is not callable using a non-shared object
 }
 synchronized void inc() {
 ++count;//testThread.d(11): Deprecation:
 read-modify-write operations are not allowed for shared variables. Use
 core.atomic.atomicOp!+=(this.count, 1) instead.
 }
 }
 void main() {
 auto thr = new DerivedThread();
 thr.start();
 thr.inc();  //testThread.d(17): Error: shared method
 testThread.DerivedThread.inc is not callable using a non-shared object
 thr.join();
 }


 1. Should I declare thr as shared? But
 auto thr = new shared DerivedThread();
 does not resolve it.

 2. Why ++count cause an error? I think it is safe because
 it is marked as synchronized. If it is forced to use atomicOp
 all the time, it's painful.

 3. Are there any tutorials about using Thread class?

 Aki.




Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread maarten van damme via Digitalmars-d-learn
While d can be complex, there's nothing preventing you from starting out
simple and not using all features at first.
I don't understand why it's not suitable for a beginner if you use this
approach...

2014-10-17 6:51 GMT+02:00 via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 On Friday, 17 October 2014 at 01:14:34 UTC, bearophile wrote:

 Python is probably a better first language than Java. D is a
 little too much complex as first language.


 The IDE support is probably a bit better with Java/C# and using a
 statically typed language as your first language has advantages, but all
 are good first languages: easy to find tutorials, easy to find educational
 example code, easy to find answers to typical beginner issues on
 Stackoverflow…

 I personally think Logo, Processing and Scheme would be more fun as
 learning tools, but they are throw-away languages. E.g.
 http://turtleacademy.com/programs/en http://www.processing.org/ and many
 more online programming sites.





Re: D with no druntime

2014-08-21 Thread maarten van damme via Digitalmars-d-learn
There were 2 talks about bare metal D this year at the D conference.

The first one is about someone able to use D on microcontrollers with a few
k ram.:
https://www.youtube.com/watch?v=o5m0m_ZG9e8

The second one is about someone trying to strip almost everything out and
see what works:
https://www.youtube.com/watch?v=qErXPomAWYI

They both go through the process of striping down the runtime and showing
what works.


2014-08-21 7:13 GMT+02:00 uri via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 Hi All,

 I am playing with a small hack OS for fun and in 2066 there are these
 undefined refs (I have no druntime):

 _d_arraybounds (new to 2066)
 _d_assert (new to 2066)
 _d_unittest (new to 2066)
 _Dmodule_ref (also in 2065)
 _d_dso_registry (also in 2065)

 It is trivial to stub these out but it got me wondering...

 Is there any way to compile D that has no dependencies?


 Thanks,
 uri






Re: Command Line Application in D

2014-08-04 Thread maarten van damme via Digitalmars-d-learn
I am a little bit confused as to what you want.
There is a command line example at dlang.org, and there exists a program
(rdmd) that compiles several D files and runs them.
http://dlang.org/rdmd.html


2014-08-04 23:20 GMT+02:00 TJB via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 I am trying to build some simple command line applications that I have
 written in python as a way to learn D. Can you give some examples for me?
 For instance, I think I remember once seeing somewhere in the documentation
 an example that took several D files and compiled them all by running some
 kind of system command.

 I much appreciate your help!

 TJB



std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
an anyone explain me what I'm doing wrong here :

[code]
dstring[][dstring] providor_symbol_map;
...

writeln(providor_symbol_map.keys.sort!((x,y)=providor_symbol_map[x].length=providor_symbol_map[y].length));
[/code]

output:
core.exception.RangeError@std.algorithm(9429): Range violation


Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
I'm trying to analyze the usage of certain words in a large number of spam
emails, and I want for every interesting word a list of 'providors', that
mentioned that word. with associative arrays I hoped to get it by using
array[interestingworde].

And I have to refer outside from sort(x,y) as associative arrays have no
order, I'll always have to sort a key-array according to values obtained
through the associative array.
It's supposed to be a delegate anyway, otherwise the least it could do is
throw a compilation error.


2014-05-28 12:53 GMT+02:00 Wanderer via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 On Wednesday, 28 May 2014 at 10:10:41 UTC, maarten van damme via

 Digitalmars-d-learn wrote:

 an anyone explain me what I'm doing wrong here :

 [code]
 dstring[][dstring] providor_symbol_map;
 ...

 writeln(providor_symbol_map.keys.sort!((x,y)=providor_
 symbol_map[x].length=providor_symbol_map[y].length));
 [/code]

 output:
 core.exception.RangeError@std.algorithm(9429): Range violation


 dstring[][dstring] declaration looks a bit obscure to me...
 what do you intent with it, array of maps or map of arrays?

 Also, it looks unnatural that inside sorting lambda, you refer
 outside from it (back to providor_symbol_map variable). Ideally,
 you should only use variables x and y. Does D support sorting by
 map entries instead of by keys only or by values only?



Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
wow.
senpai, teach me what I did wrong...


2014-05-28 13:21 GMT+02:00 bearophile via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com:

 maarten van damme:


  writeln(providor_symbol_map.keys.sort!((x,y)=providor_
 symbol_map[x].length=providor_symbol_map[y].length));
 [/code]


 Try:

 ((x, y) = providor_symbol_map[x].length  providor_symbol_map[y].length)

 Bye,
 bearophile