Re: Why doesn't this chain of ndslices work?

2016-05-15 Thread Stiff via Digitalmars-d-learn

On Sunday, 15 May 2016 at 08:31:17 UTC, 9il wrote:

On Saturday, 14 May 2016 at 21:59:48 UTC, Stiff wrote:

Here's the code that doesn't compile:

import std.stdio, std.experimental.ndslice, std.range, 
std.algorithm;


[...]


Coming soon 
https://github.com/libmir/mir/issues/213#issuecomment-219271447 
--Ilya


Awesome, thanks to both of you. I think I can get what I want 
from mir.sparse. I was aware of it, but hadn't made the 
connection to what I'm trying to do for some reason.


More generally, I'm eagerly looking forward to a more complete 
Mir. I've been using bindings to GSL for non-uniform (and quasi-) 
random number generation, and a cleaner interface would be great. 
I'll be watching on github.


Why doesn't this chain of ndslices work?

2016-05-14 Thread Stiff via Digitalmars-d-learn

Here's the code that doesn't compile:

import std.stdio, std.experimental.ndslice, std.range, 
std.algorithm;


void main()
{
auto alloslice = [1, 2, 3, 4].sliced(1,4);
auto sandwich = chain(alloslice,
(0).repeat(8).sliced(2,4),
alloslice);
writeln(sandwich);
}

If I comment out the line with the repeat, or allocate the repeat 
with .array(), everything is fine. I get that the types are 
incompatible in some way, but it seems like I should be able to 
lazily instantiate those zeros whenever I need to (later). Should 
this work? Is there a different way to set up all of the ranges 
without allocating everything up front?


And yeah, resources aren't particularly limited for my 
application, so allocating everything wouldn't hurt, but I'm 
trying to really understand all of these little details about 
ranges. I love them when they work, but the learning curve has 
been steep.


Re: Linker error from dub?

2015-11-16 Thread Stiff via Digitalmars-d-learn

On Thursday, 12 November 2015 at 06:11:37 UTC, BBasile wrote:

On Thursday, 12 November 2015 at 06:03:49 UTC, BBasile wrote:
It worked fine because it was not used, not parsed, not 
linked. Maybe just the functions declarations was parsed to 
solve the symbols in the program, but since none was used the 
'import blas.blas' was eliminated or something like that. This 
could be explained better by someone who knows well DMD 
architecture...


I think that you would get an error with just the 'import 
blas.blas' and building the debug config.


I've spotted a std.expirmental.allocators bug this summer that 
was revealed in by a similar scheme: extern declaration not 
used in release mode, but in debug mode the symbols, even if 
not used, were not eliminated and the compiler complained about 
undefined symbol this & that !


It's been a few days, but I just wanted to say thanks for the 
help. I was able to fix the problem by linking to cblas in my 
dub.json.


Re: Linker error from dub?

2015-11-11 Thread Stiff via Digitalmars-d-learn

On Thursday, 12 November 2015 at 05:17:58 UTC, BBasile wrote:

On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:

Possibly a dumb question, I'm not sure.
[...]
undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!


You should add something to tell DUB to link your program with 
the openblas static library since cblas is just a binding. For 
example this should work:


{
 "name" : "tcbuilder",
 "description" : "Thalamocortical network parameter 
parser",

 "dependencies" : {
 "cblas": "~>0.1.0",
 "scid": "~>0.3.0"
 },
 "libs" : [
   "openblas"
 ],
}

And install the 'openblas-devel' package of course. Btw I've 
verified with a simple program and it works, although it just 
included cblas, not scid.


Does the libs element from cblas' dub.json not handle that 
library linkage? I suppose I should also mention that it was 
compiling fine before I actually used a function from the library 
in my code.


If it does work with OpenBLAS, that would seem to suggest that 
"Works with OpenBLAS and others" is a bit more restrictive than 
it sounds...


Linker error from dub?

2015-11-11 Thread Stiff via Digitalmars-d-learn

Possibly a dumb question, I'm not sure.

I'm trying to use the cblas headers from DLangScience, and 
getting linker errors out of dub when trying to build my project. 
I'm only trying to call gemm(), so it should be pretty 
straightforward.


Anyway, my dub.json:

{
"name" : "tcbuilder",
"description" : "Thalamocortical network parameter 
parser",

"dependencies" : {
"cblas": "~>0.1.0",
"scid": "~>0.3.0"
}
}

and the output from `dub build`:

Performing "debug" build using dmd for x86_64.
cblas 0.1.0: target for configuration "library" is up to date.
scid 0.3.0: target for configuration "library" is up to date.
tcbuilder ~master: building configuration "application"...
blasint = int
Linking...
.dub/build/application-debug-linux.posix-x86_64-dmd_2069-8ECAC666F541E423658AC8BE09AB7073/tcbuilder.o:
 In function 
`_D3app18__T10matrixMultTdZ10matrixMultFNbxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewZS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixView':
/home/stiff/Projects/TCBuilder/source/app.d:248: undefined 
reference to `cblas_dgemm'

collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!