Re: Why am I getting a dividing by zero error message

2021-01-28 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 [...] It might help to separate break this out into smaller functions. May make it easier to follow what is happening.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 16:22:59 UTC, IGotD- wrote: [snip] Are we talking about the same things here? You mentioned DMD but I was talking about programs compiled with DMD (or GDC, LDC), not the nature of the DMD compiler in particular. Bump the pointer and never return any memory

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 15:36:37 UTC, Ola Fosheim Grøstad wrote: On Friday, 15 January 2021 at 15:20:05 UTC, jmh530 wrote: Hypothetically, would it be possible for users to supply their own garbage collector that uses write barriers? Yes. You could translate Google Chrome's Oilpan to D.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:50:00 UTC, welkam wrote: On Thursday, 14 January 2021 at 18:51:16 UTC, Ola Fosheim Grøstad wrote: One can follow the same kind of reasoning for D. It makes no sense for people who want to stay high level and do batch programming. Which is why this disconnect

Re: C++ or D?

2020-12-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 December 2020 at 19:51:07 UTC, Ola Fosheim Grøstad wrote: [snip] Sort of, in C++ it would be something like this template class OuterName> void myfunction(OuterName x){ stuff(); } [snip] You mean like this struct Foo(T) { T x; } void foo(T : Foo!V, V)(T x) {

Re: Running unit tests from DUB single file packages

2020-12-22 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 15:06:09 UTC, drug wrote: [snip] But what do you mean exactly by "work with dependency"? As I understand, `dub test` does not run unit tests in dependencies and single file packages work with dependencies in general. Do you mean something else? I'm finishing

Re: Running unit tests from DUB single file packages

2020-12-21 Thread jmh530 via Digitalmars-d-learn
On Monday, 21 December 2020 at 11:31:49 UTC, drug wrote: [snip] Unfortunately I'm very busy. But I check it again and it turns out that the fix does not resolve the problem completely. This PR just remove the single file from testing so currently dub does not run unit tests in the single file

Re: Running unit tests from DUB single file packages

2020-12-20 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 12:51:11 UTC, drug wrote: [snip] Thanks! Let's see if it gets merged or if a slightly more involved solution is needed. Remake it - https://github.com/dlang/dub/pull/2052 This has more chances to be merged Looks like this got merged and will be part of

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 14:15:22 UTC, Johannes Loher wrote: [snip] The point of using DUB (and the single file package format) is easy access to libraries from the DUB registry. If I didn't want to use a dependency, I would not be using DUB at all. That said, leaving out the

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1] https://adventofcode.com/ Have you tried it without the imports?

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 13:52:35 UTC, jmh530 wrote: On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1]

Re: lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
On Friday, 20 November 2020 at 14:57:42 UTC, H. S. Teoh wrote: On Fri, Nov 20, 2020 at 02:47:52PM +, Paul Backus via Digitalmars-d-learn wrote: [...] In this specific case, you could also make `foo` a type-safe variadic function [1], which would eliminate the need for `allSatisfy`:

lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
Doing something like below fails because I don't seem to be able to make a templated lambda that just takes types. Is the only way to do something similar to create a separate function to handle the condition, or is there some other way to do something with similar flexibility? import

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:53:48 UTC, Mike Parker wrote: [snip] I can attest that in the 17 years I've been hanging around here, the fact that enum is used to indicate a manifest constant has not been a serious source of WTF posts. So I think "pretty much everyone coming to D" have

Re: How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-09 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 9 September 2020 at 15:30:33 UTC, Shaleen Chhabra wrote: [snip] Hi, I updated my dmd version to dmd-2.093.1 Now it throws a conflict error between 1. function mir.ndslice.topology.iota!(long, 1LU).iota at mir/ndslice/topology.d(630) conflicts with function

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread jmh530 via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:39:44 UTC, H. S. Teoh wrote: [snip] "Furthermore, it can dispatch to a type-erased implementation ala Java -- at your choice;" This is interesting. Would you just cast to Object?

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 18:09:50 UTC, ag0aep6g wrote: [snip] `is(...)` only works on types. You're looking for `__traits(isSame, T, Foo)`. For `is(T!U == Foo!U, U)` to work, the compiler would have to guess U. If the first guess doesn't work, it would have to guess again, and again,

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 16:01:35 UTC, jmh530 wrote: [snip] It seems as if the T is properly Foo(T) and can only be instantiated with actual types. Something like below works and might work for me. template test(alias T) if (__traits(isTemplate, T)) { void test(U)(U x)

Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
The code below compiles, but I want to put an additional constraint on the `test` function is only called with a Foo struct. I tried things like is(T == Foo) and is(T : Foo), but those don't work. However, something like is(T!int : Foo!int) works, but is(T!U == Foo!U, U) doesn't. Any idea

Re: 2-D array initialization

2020-08-02 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 August 2020 at 19:19:51 UTC, Andy Balba wrote: I'm not a gitHub fan, but I like the mir functions; and it looks like I have to download mir before using it. mir has quite a few .d files..Is there a quick way to download it ? dub [1] is now packaged with dmd, which is the

Re: 2-D array initialization

2020-07-31 Thread jmh530 via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: ubyte[3][4] c ; How does one initialize c in D ? none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; c[0] = ubyte[3] [5, 5, 5] ; c[1] = ubyte[3] [15, 15,15] ; c[2] =

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:41:35 UTC, 9il wrote: [snip] Ah, no, my bad! You write @fmamath, I have read it as @fastmath. @fmamath is OK here. I've mixed up @fastmath and @fmamath as well. No worries.

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:26:19 UTC, 9il wrote: [snip] @fmamath private double sd(T)(Slice!(T*, 1) flatMatrix) @fastmath violates all summation algorithms except `"fast"`. The same bug is in the original author's post. I hadn't realized that @fmamath was the problem, rather than

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 05:57:56 UTC, tastyminerals wrote: [snip] Here is a (WIP) project as of now. Line 160 in https://github.com/tastyminerals/mir_benchmarks_2/blob/master/source/basic_ops.d std of [60, 60] matrix 0.0389492 (> 0.001727) std of [300, 300] matrix 1.03592 (> 0.043452)

Re: D Mir: standard deviation speed

2020-07-14 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 19:04:45 UTC, tastyminerals wrote: I am trying to implement standard deviation calculation in Mir for benchmark purposes. I have two implementations. One is the straightforward std = sqrt(mean(abs(x - x.mean())**2)) and the other follows Welford's algorithm for

Re: Upcoming refraction module in bolts [was: DUB project type support for Emacs Projectile]

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 17:32:26 UTC, Jean-Louis Leroy wrote: [snip] Thanks, cool.

Re: DUB project type support for Emacs Projectile

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 13:17:11 UTC, Jean-Louis Leroy wrote: [snip] Nah, I saw it. Well. My take on it has been ready for months but I had to wait for my employer's permission to publish it. They are very open-source friendly, and as a consequence there is a glut of requests for

Re: DUB project type support for Emacs Projectile

2020-06-14 Thread jmh530 via Digitalmars-d-learn
On Sunday, 14 June 2020 at 17:19:05 UTC, Jean-Louis Leroy wrote: [snip] In case you missed it, I thought you would find this interesting https://forum.dlang.org/thread/dytpsnkqnmgzniiwk...@forum.dlang.org

Re: Why is there no range iteration with index by the language?

2020-06-10 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote: [snip] Anyhow, I would be highly in favor of DMD doing this. It's one of those many things that I have on my list for D3 or a D fork. Chapel supports zippered iteration [1]. From the discussion here, it sounds very much like the

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 14:27:26 UTC, data pulverizer wrote: [snip] Out of curiosity what does the "." in front of `foo` mean? I've seen that in some D code on the compiler in GitHub and have no idea what it does. I tried Googling it to no avail. It doesn't have anything to do with UFCS

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 12:20:46 UTC, Adam D. Ruppe wrote: [snip] Why do you even want foo!"fabs"? Usually when I see people having this problem it is actually a misunderstanding of what is possible with the foo!fabs style - which is better in basically every way and can be used in most

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 10:28:39 UTC, Paul Backus wrote: [snip] Thanks for that suggestion. That works for me. Unfortunately, it's probably not worth the extra effort though, versus doing foo!fabs in my case.

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 04:13:08 UTC, Mike Parker wrote: [snip] The problem isn't the mixin. It's the template. Templates take the scope of their declaration, not their instantiation. So the mixin is getting the template's scope. Anyway, this appears to work: `double z =

Mixin and imports

2020-06-07 Thread jmh530 via Digitalmars-d-learn
In the code below, foo!fabs compiles without issue, but foo!"fabs" does not because the import is not available in the string mixin. If I move the import to the top of the module, then it works. However, then if I move foo to another module, then it will no longer compile since it is in

Re: Mir Slice Column or Row Major

2020-05-27 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 May 2020 at 00:51:50 UTC, 9il wrote: snip Actually it is a question of notation. For example, mir-lapack uses ndslice as column-major Fortran arrays. This may cause some headaches because the data needs to be transposed in mind. We can think about ndslice as about column-major

Re: Mir Slice Column or Row Major

2020-05-27 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 16:07:58 UTC, welkam wrote: On Wednesday, 27 May 2020 at 01:31:23 UTC, data pulverizer wrote: column major Cute puppies die when people access their arrays in column major. Not always true...many languages support column-major order (Fortran, most obviously).

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 15:18:42 UTC, jmh530 wrote: On Tuesday, 26 May 2020 at 15:16:25 UTC, jmh530 wrote: [snip] Another short-term fix might be to try compiling with the -m32 dflag (need to put in your dub.sdl/json). Sorry, easier is dub test --arch=x86 You may also have to make

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 15:26:48 UTC, BoQsc wrote: [snip] Linking... lld-link: error: could not open libcmt.lib: no such file or directory lld-link: error: could not open OLDNAMES.lib: no such file or directory Error: linker exited with status 1 C:\D\dmd2\windows\bin\dmd.exe failed with

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 15:16:25 UTC, jmh530 wrote: [snip] Another short-term fix might be to try compiling with the -m32 dflag (need to put in your dub.sdl/json). Sorry, easier is dub test --arch=x86

Re: Static assert triggered in struct constructor that shouldn't be called

2020-05-24 Thread jmh530 via Digitalmars-d-learn
On Sunday, 24 May 2020 at 21:43:34 UTC, H. S. Teoh wrote: On Sun, May 24, 2020 at 09:34:53PM +, jmh530 via Digitalmars-d-learn wrote: The following code results in the static assert in the constructor being triggered, even though I would have thought no constructor would have been called

Static assert triggered in struct constructor that shouldn't be called

2020-05-24 Thread jmh530 via Digitalmars-d-learn
The following code results in the static assert in the constructor being triggered, even though I would have thought no constructor would have been called. I know that there is an easy fix for this (move the static if outside the constructor), but it still seems like it doesn't make sense.

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread jmh530 via Digitalmars-d-learn
On Sunday, 24 May 2020 at 14:21:26 UTC, Pavel Shkadzko wrote: [snip] Sorry for the typo. It should be "auto arrSlice = a.sliced;" Try using fuse /+dub.sdl: dependency "mir-algorithm" version="*" +/ import std.stdio; import std.conv; import std.array: array; import std.range: chunks; import

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 17:59:30 UTC, Paul Backus wrote: On Thursday, 7 May 2020 at 15:00:18 UTC, jmh530 wrote: Does foo!y0(rt) generate the same code as foo(rt, y0)? How is the code generated by foo(rt, x0) different from foo(rt,y0)? You can look at the generated code using the Compiler

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:34:21 UTC, ag0aep6g wrote: [snip] The `static if` is guaranteed to be evaluated during compilation. That means, `foo!y0` effectively becomes this: auto foo(int rt) { return rt + 1; } There is no such guarantee for `foo(rt, y0)`. It doesn't matter that y0

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:29:01 UTC, H. S. Teoh wrote: [snip] You explained things very well, thanks.

CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
I am curious how ctfe and static ifs interact. In particular, if an enum bool passed as a template parameter or run-time one will turn an if statement into something like a static if statement (perhaps after the compiler optimizes other code away). In the code below, I am a function that takes

Re: Python eval() equivalent in Dlang working in Runtime?

2020-05-01 Thread jmh530 via Digitalmars-d-learn
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote: There is a Python eval() equivalent in Dlang working in Runtime? You might find arsd's script.d interesting [1], but it's more like a blend between D and javascript.

Re: Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
On Monday, 27 April 2020 at 17:40:06 UTC, Steven Schveighoffer wrote: [snip] Thanks for that. Very detailed. In terms of a use case, we just added a center function to mir [1]. It can take an alias to a function. I wanted to add a check that the arity of the function was 1, but it turned

Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
When using a template with multiple functions within it, is it possible to access the underlying functions directly? Not sure I am missing anything, but what works when the functions are named differently from the headline template doesn't work when the functions are named the same. import

Attribute inference within template functions

2020-04-22 Thread jmh530 via Digitalmars-d-learn
I was trying to write a function has different behavior depending on whether it is called from @nogc code or not. However, I am noticing that this does not seem possible because of the timing of attribute inference. If I call getFunctionAttributes within foo below, then it is system but then

Re: Multiplying transposed matrices in mir

2020-04-20 Thread jmh530 via Digitalmars-d-learn
On Monday, 20 April 2020 at 19:06:53 UTC, p.shkadzko wrote: [snip] It is. I was trying to calculate the covariance matrix of some dataset X which would be XX^T. Incorrect. The covariance matrix is calculated with matrix multiplication, not element-wise multiplication. For instance, I often

Re: mir: How to change iterator?

2020-04-20 Thread jmh530 via Digitalmars-d-learn
On Monday, 20 April 2020 at 00:27:40 UTC, 9il wrote: [snip] Using two arguments Iterator1, Iterator2 works without allocation /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator1, Iterator2, SliceKind kind) (Slice!(Iterator1, 1, kind) x,

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: 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 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

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: mir: How to change iterator?

2020-04-16 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 19:59:57 UTC, Basile B. wrote: [snip] And remove the extra assert() BTW... I don't know why this is accepted. Thanks, I hadn't realized about approxEqual. I think that resolves my near-term issue, I would need to play around with things a little more to be

mir: How to change iterator?

2020-04-14 Thread jmh530 via Digitalmars-d-learn
In the code below, I multiply some slice by 5 and then check whether it equals another slice. This fails for mir's approxEqual because the two are not the same types (yes, I know that isClose in std.math works). I was trying to convert the y variable below to have the same double* iterator as

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:29:17 UTC, Anonymouse wrote: [snip] It works with `ref int` too. ``` __gshared int gshared = 42; void foo(ref int i = gshared) @safe { ++i; } void main() { assert(gshared == 42); foo(); assert(gshared == 43); } ``` Well that definitely

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 18:50:16 UTC, data pulverizer wrote: On Wednesday, 8 April 2020 at 16:53:05 UTC, Anonymouse wrote: ``` import std.stdio; @safe: __gshared int gshared = 42; void foo(int i = gshared) { writeln(i); } void main() { foo(); } ``` This currently works; `foo`

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 with

Re: dub libs from home directory on windows

2020-03-18 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 18 March 2020 at 15:10:52 UTC, Виталий Фадеев wrote: On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote: I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name. Thank you very much for your help. I

Re: How to sort 2D Slice along 0 axis in mir.ndslice ?

2020-03-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 06:12:55 UTC, 9il wrote: [snip] Almost the same, just fixed import for `each` and a bit polished /+dub.sdl: dependency "mir-algorithm" version="~>3.7.18" +/ import mir.ndslice; import mir.ndslice.sorting; import mir.algorithm.iteration: each; void main() {

Re: How to sort 2D Slice along 0 axis in mir.ndslice ?

2020-03-10 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 10 March 2020 at 23:31:55 UTC, p.shkadzko wrote: [snip] Below does the same thing as the numpy version. /+dub.sdl: dependency "mir-algorithm" version="~>3.7.18" +/ import mir.ndslice.sorting : sort; import mir.ndslice.topology : byDim; import mir.ndslice.slice : sliced; void

Re: Improving dot product for standard multidimensional D arrays

2020-03-03 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 3 March 2020 at 10:25:27 UTC, maarten van damme wrote: 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. [snip] And of course there's going to be a

Re: Improving dot product for standard multidimensional D arrays

2020-03-02 Thread jmh530 via Digitalmars-d-learn
On Monday, 2 March 2020 at 20:22:55 UTC, p.shkadzko wrote: [snip] Interesting growth of processing time. Could it be GC? +--+-+ | matrixDotProduct | time (sec.) | +--+-+ | 2x[100 x 100]|0.01 | | 2x[1000 x 1000] |2.21

Re: Improving dot product for standard multidimensional D arrays

2020-03-02 Thread jmh530 via Digitalmars-d-learn
On Monday, 2 March 2020 at 18:17:05 UTC, p.shkadzko wrote: [snip] I tested @fastmath and @optmath for toIdx function and that didn't change anyting. @optmath is from mir, correct? I believe it implies @fastmath. The latest code in mir doesn't have it doing anything else at least.

Re: Improving dot product for standard multidimensional D arrays

2020-03-02 Thread jmh530 via Digitalmars-d-learn
On Monday, 2 March 2020 at 13:35:15 UTC, p.shkadzko wrote: [snip] Thanks. I don't have time right now to review this thoroughly. My recollection is that the dot product of two matrices is actually matrix multiplication, correct? It generally makes sense to defer to other people's

Re: Improving dot product for standard multidimensional D arrays

2020-03-02 Thread jmh530 via Digitalmars-d-learn
On Sunday, 1 March 2020 at 20:58:42 UTC, p.shkadzko wrote: Hello again, [snip] What compiler did you use and what flags?

Re: How to sum multidimensional arrays?

2020-02-27 Thread jmh530 via Digitalmars-d-learn
On Thursday, 27 February 2020 at 16:39:15 UTC, 9il wrote: [snip] Few performances nitpick for your example to be fair with benchmarking againt the test: 1. Random (default) is slower then Xorfish. 2. double is twice larger then int and requires twice more memory, so it would be twice slower

Re: How to sum multidimensional arrays?

2020-02-27 Thread jmh530 via Digitalmars-d-learn
On Thursday, 27 February 2020 at 15:28:01 UTC, p.shkadzko wrote: On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote: This works but it does not look very efficient considering we flatten and then calling array twice. It will get even worse with 3D arrays. And yes, benchmarks

Re: 2D matrix operation (subtraction)

2020-02-25 Thread jmh530 via Digitalmars-d-learn
On Saturday, 22 February 2020 at 08:29:32 UTC, 9il wrote: [snip] Maybe mir.series [1] can work for you. I had a few other thoughts after looking at septc's solution of using y[0..$, 0] *= 100; to do the calculation. 1) There is probably scope for an additional select function to handle

Re: 2D matrix operation (subtraction)

2020-02-21 Thread jmh530 via Digitalmars-d-learn
On Friday, 21 February 2020 at 14:43:37 UTC, jmh530 wrote: [snip] Actually, I kind of prefer the relevant line as x.byDim!1[0].each!"a -= 2"; which makes it a little clearer that you can easily change [0] to [1] to apply each to the second column instead.

Re: 2D matrix operation (subtraction)

2020-02-21 Thread jmh530 via Digitalmars-d-learn
On Friday, 21 February 2020 at 11:53:02 UTC, Ali Çehreli wrote: [snip] auto byColumn(R)(R range, size_t n) { return Column!R(range, n); } mir has byDim for something similar (numir also has alongDim). This is how you would do it: import mir.ndslice; void main() { auto x = [0.0, 1.4,

Re: matrix operations

2019-11-27 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 27 November 2019 at 16:16:04 UTC, René Heldmaier wrote: Hi, I'm looking for some basic matrix/vector operations and other numeric stuff. I spent quite a lot time in reading through the mir documentation, but i kinda miss the bigger picture. I'm not a Python user btw. (I know

Re: CI: Why Travis & Circle

2019-11-16 Thread jmh530 via Digitalmars-d-learn
On Saturday, 16 November 2019 at 09:07:45 UTC, Petar Kirov [ZombineDev] wrote: [snip] Most likely the reason is parallelism. Every CI service offers a limited amount of agents that can run in parallel, which limits the number of test matrix combinations that you can run in a reasonable

Re: CI: Why Travis & Circle

2019-11-14 Thread jmh530 via Digitalmars-d-learn
On Thursday, 14 November 2019 at 17:06:36 UTC, Andre Pany wrote: [snip] With the public availability of Github Actions I highly recommend it if you have open source project on Github. If is free and works well with D and Dub. Kind regards Andre I'm not that familiar with Github Actions,

CI: Why Travis & Circle

2019-11-14 Thread jmh530 via Digitalmars-d-learn
I'm curious what the typical motivation is for using both Travis CI and Circle CI in a project is. Thanks.

Re: Running unittests of a module with -betterC

2019-10-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 October 2019 at 18:45:50 UTC, Jacob Carlborg wrote: On 2019-10-30 16:09, jmh530 wrote: I feel like this should be added into the compiler so that it just works. This will only run the unit tests in the current modules. The standard way of running the unit tests will run the

Re: Running unittests of a module with -betterC

2019-10-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 October 2019 at 15:09:40 UTC, jmh530 wrote: [snip] I feel like this should be added into the compiler so that it just works. Hmm, maybe only when compiled with -main, but I don't think there's a version for that.

Re: Running unittests of a module with -betterC

2019-10-30 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 08:45:15 UTC, mipri wrote: [snip] -unittest sets the 'unittest' version identifier. So this works: unittest { assert(0); } version(unittest) { extern(C) void main() { static foreach(u; __traits(getUnitTests, __traits(parent, main)))

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread jmh530 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 17:41:21 UTC, Dukc wrote: This was wrong: Atila's Excel-d enables writing plugin functions, but not reading the spreadsheets. There are other DUB utilities for that, though. I quess I will give my employer two options: Either the price variables are in an

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread jmh530 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:20:20 UTC, jmh530 wrote: On Thursday, 24 October 2019 at 16:03:26 UTC, Dukc wrote: [snip] If they are only opening it in Excel, then you can lock cells. You should be able to do that with VBA. At least I know it works with xlsx files. Not sure on csv now

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread jmh530 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:03:26 UTC, Dukc wrote: [snip] If they are only opening it in Excel, then you can lock cells. You should be able to do that with VBA.

Re: Meta question - what about moving the D - Learn Forum to a seperate StackExchange platform?

2019-10-18 Thread jmh530 via Digitalmars-d-learn
On Friday, 18 October 2019 at 07:35:21 UTC, Martin Tschierschke wrote: [snip] I think this is something that's been proposed before, but most people are happy with just asking a question here and usually people are pretty good about helping out with answers when possible.

Re: Reading parquet files from D

2019-10-14 Thread jmh530 via Digitalmars-d-learn
On Monday, 14 October 2019 at 19:27:04 UTC, Andre Pany wrote: [snip] I found this tool https://github.com/gtkd-developers/gir-to-d from Mike Wey which translates GObject GIR files to D headers. It might be interesting for some of this functionality to get included in dpp.

Re: How Different Are Templates from Generics

2019-10-12 Thread jmh530 via Digitalmars-d-learn
On Saturday, 12 October 2019 at 21:44:57 UTC, Jonathan M Davis wrote: [snip] Thanks for the reply. As with most people, I don't write a lot of D code that uses classes that much. The use case I'm thinking of is with allocators, which - to be honest - is not something I deal with much in

Re: How Different Are Templates from Generics

2019-10-12 Thread jmh530 via Digitalmars-d-learn
On Friday, 11 October 2019 at 17:50:42 UTC, Jonathan M Davis wrote: [snip] A very thorough explanation! One follow-up question: would it be possible to mimic the behavior of Java generics in D?

Re: C#'s 'is' equivalent in D

2019-10-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 October 2019 at 16:33:47 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 03:58:02PM +, jmh530 via Digitalmars-d-learn wrote: On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: > In C# you can do something like: > > > if (obj is Person) >

Re: C#'s 'is' equivalent in D

2019-10-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: In C# you can do something like: if (obj is Person) { var person = obj as Person; // do stuff with person... } where you can check the type of an object prior to casting. Does D have a similar

Re: matplotlibD returns

2019-09-17 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 01:54:01 UTC, Brett wrote: How does one get return values? https://matplotlib.org/3.1.0/gallery/statistics/hist.html Shows that python uses return values to set properties of the plot

1 new

2019-08-02 Thread jmh530 via Digitalmars-d-learn
When I navigate to https://forum.dlang.org/ I have a message that says "1 new reply" to "your posts." Normally, I click on that "1 new reply" and find the post that's new, go to it, and the message disappears. However, it doesn't seem to go away anymore. I tried looking at many different old

Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post

2019-03-12 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 15:35:03 UTC, Ron Tarrant wrote: [snip] It's a learning resource, so wouldn't that go here? Or am I misinterpreting the intention of the Learn sub-forum? If you a moderator believes it should move, please feel free. It's a learning resource, sure, but you're

Re: Why does D language do not support BigDecimal type?

2019-03-12 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 09:31:53 UTC, Boqsc wrote: [snip] Please attach quick working examples for every sentence you write or it's just a waste of time. People want to see the results and direct actions first before anything else, it's more efficient communication. We are in the

Re: ggplotd Fixed ratio between x and y axes

2019-03-12 Thread jmh530 via Digitalmars-d-learn
On Monday, 11 March 2019 at 23:34:06 UTC, kerdemdemir wrote: How can I configure a fixed ratio between x and y axes in ggplotd ? I easily found what I am looking for in ggplot which ggplotd inspires a lot. http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/ But ggplotd documentation does not

Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post

2019-03-12 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 14:44:59 UTC, Ron Tarrant wrote: It was suggested that I do all these posts in one thread, so this is the thread where that'll happen. With that said... [snip] I thought the suggestion was one thread in the Announce forum, rather than multiple threads in the

Re: How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread jmh530 via Digitalmars-d-learn
On Monday, 11 March 2019 at 20:11:37 UTC, ag0aep6g wrote: On Monday, 11 March 2019 at 19:53:53 UTC, jmh530 wrote: So what information is in the static library that allows this to take place? None. The information is in in the source or interface file (.d/.di). Templates can't be compiled

How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread jmh530 via Digitalmars-d-learn
Suppose I have a file with a simple templated function. I compile that to a static library. I then compile another file that uses the library into an executable. When compiled to the static library, you don't know in advance what types it will call on the templated function, so that must be

Re: int[] as constructor

2018-12-04 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 4 December 2018 at 22:35:48 UTC, Jonathan M Davis wrote: On Tuesday, December 4, 2018 3:17:04 PM MST jmh530 via Digitalmars-d-learn wrote: I've noticed that I can use int like a constructor, as in: int x = int(1); but I can't do the same thing with slices int[] y = int

  1   2   3   4   >