dlangscience / scid Goto Github PK
View Code? Open in Web Editor NEWScientific library for the D programming language
License: Boost Software License 1.0
Scientific library for the D programming language
License: Boost Software License 1.0
scid is one of two projects causing a Jenkins CI failure for DMD (dlang/dmd#8241) and preventing us from moving forward with a deprecation. Looking through the code in scid's master branch, it appears the fix has already been made, but it needs to be tagged and released for DMD's CI to pick it up.
Hello!
I post here because this repository seems to be the only one watched by all people concerned with scid.
I want to add some modules containing scientific constants and coefficients for unit conversion.
The main difficulty is the names of the constants.
In my opinion names like "CONST_CGS_PLANCKS_CONSTANT_HBAR" are bulky and not convenient.
On the other hand, short names are less informative.
I would suggest the following:
By the way, should the names of constants be in CAPITAL letters?
What do you think about this?
I have created the ScientificD "organisation" here on GitHub. I hope that, in time, it will become a nexus for D's scientific programming community, and a natural place to host code related to numerics and science โ like D-Programming-Language is for the core language and D-Programming-Deimos is for C library bindings.
I don't have a clear opinion on how best to organise this, but I think it is a good idea if each library gets its own repository. That way someone can associate their library with ScientificD, yet have full control over the code that gets committed to it. Personally, I intend to split the current SciD into several libraries (one for quadrature, one for differentiation, one for nonlinear equations, etc.) and host them all at ScientificD.
Some functionality will most likely be useful for several libraries, yet still too niche for Phobos. For those things, a "core" repository should be made, upon which the other libraries can depend. (Of course, the maintainer(s) of such a library should be very careful about keeping backwards compatibility as much as possible, so they don't break a bunch of other libraries with a commit.)
Opinions, anyone? Ideas about organisation? Is the "one repo per library" idea a good one? If so, should there still be a common build system?
As it currently stands, the MatrixView struct in scid.matrix only provides the functionality to access elements with the opIndex and opIndexAssign overloaded operators.
It would be nice to have the arithmetic operators overloaded to provide elementwise operations. This would allow code like:
auto matrix_3 = 2 * matrix_1 - 1.5 * matrix_2^^2
Also I couldn't find any dot product for matrices. Following the nomenclature in std.numeric we could call this function dotProduct, so we could have code like:
auto Z = dotProduct(X, Y)
Is there any reason I overlooked why this has not been included? If it is just a lack of contributors, I'm already developing some of this stuff, and I will open a pull request so others can improve or point out possible errors in my code. When it is ready, it would be nice to merge it into the main repo.
...as soon as it actually gets included in Phobos, that is.
Thanks for sharing SciD, it looks like exactly what I would need! Unfortunately, I have been unable to compile/link a simple test example. I am not sure I got it right from installation to compilation/linking, though. I didn't find detailed instructions for those. Perhaps I did something wrong - this is what I did:
But while dmd (or rather ld) clearly finds most symbols in libscid.a and liblapack it fails to find the following one:
Undefined symbols for architecture x86_64:
"_D4scid6linalg35__T4det_TdVE4scid6matrix7Storagei0Z4det_FS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewZ3mulMFdZv", referenced from:
_D4scid6linalg35__T4det_TdVE4scid6matrix7Storagei0Z4det_FS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewZd in main.o
In case that matters, I am on Mac OS X 10.9.5.
Many thanks for your help!
There is probably a case for the lapack bindings to exist independently of this package
If I understand correctly, the current build script hardcodes in dmd as the compiler. This is undesirable for a couple of reasons.
diff -up scid-20120429git51236f3/build.d.fix scid-20120429git51236f3/build.d
--- scid-20120429git51236f3/build.d.fix 2012-04-26 19:19:05.000000000 +0200
+++ scid-20120429git51236f3/build.d 2012-10-11 01:00:47.433973977 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env dmd -run
+#!/usr/bin/env ldc2 -run
/** Build system for SciD
@@ -8,26 +8,26 @@
Usage:
To build the library and generate header (.di) files, run
---
- rdmd build
+ ./build
---
To build only the library file, run
---
- rdmd build lib
+ ./build lib
---
To only generate header files, run
---
- rdmd build headers
+ ./build headers
---
To make the documentation, run
---
- rdmd build html
+ ./build html
---
Any command line arguments beyond the first one will be passed
on to the compiler. For example, to enable optimisations and
inlining when building the library, run
---
- rdmd build lib -O -inline
+ ./build lib -O -inline
---
*/
import std.algorithm, std.array, std.exception, std.file, std.getopt, std.path,
@@ -69,7 +69,7 @@ in { assert (args.length > 0); }
body
{
bool gdc;
- string compiler = "dmd";
+ string compiler = "ldc2";
getopt(args, std.getopt.config.passThrough, "gdc", &gdc);
if(gdc)
@@ -109,15 +109,15 @@ void buildLib(string compiler, string[]
ensureDir(libDir);
auto sources = getSources();
- version (Posix) immutable libFile = "lib"~libName~".a";
+ version (Posix) immutable libFile = "lib"~libName~"-ldc.so";
version (Windows) immutable libFile = libName~".lib";
- immutable buildCmd = compiler ~ " "
+ immutable buildldc = compiler ~ " "
~std.string.join(sources, " ")
- ~" -lib -od"~libDir~" -of"~libFile
+ ~" -shared -soname "~ libFile~".1"~" -od"~libDir~" -of"~libFile~".1.0.0"
~" "~std.string.join(extraOptions, " ");
- writeln(buildCmd);
- enforce(system(buildCmd) == 0, "Error building library");
+ writeln(buildldc);
+ enforce(system(buildldc) == 0, "Error building library");
}
@@ -201,7 +201,7 @@ void buildClean()
rm(libDir);
rm(headerDir);
rm(htmlDir);
- rm(__FILE__~".deps"); // Clean up after rdmd as well
+ rm(__FILE__~".deps"); // Clean up after ./as well
}
I see that invert is "Currently only defined for general real matrices". I don't have a good linear algebra intuition, and I can't see why the invert() function in linalg.d isn't capable of handling complex arguments. Everything I've seen suggests that ZGETRF and ZGETRI should invert a complex matrix. Is there something I'm missing?
dub test --compiler=ldc2
failed.
See https://travis-ci.org/9il/scid/jobs/46697648
or https://travis-ci.org/kyllingstad/scid/jobs/46697692
A couple of notes:
MatrixView has opIndex return by ref in order to allow array[i,j] op= v;
. The should be done with opIndexOpAssign instead.
With the new extended semantics of opIndex and opSlice, a proper NDArray type can be implemented, with multi-dimensional slicing.
build pushes
turned off?
This will allow people to use SciD in proprietary applications, while preventing them from releasing proprietary versions of the library itself.
Requested by Jordi Sayol. See issue #4 for details.
when running dub build --build=DSddox
I get
Error: unterminated character constant
Error: unterminated character constant
Error: unterminated character constant
source/scid/calculus.d(1505): Warning: Ddoc: parameter count mismatch
source/scid/ports/minpack/dogleg.d(46): Warning: Ddoc: parameter count mismatch
source/scid/types.d(207): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
Please update README after #22. I think few words about building with dub, Travis CI shield and link to the documentation http://ddocs.org/scid/latest/scid/functions.html can help users.
#!/usr/bin/env ldc2 -run
/** Build system for SciD
This is an experimental build system for SciD, using a regular D
script instead of a makefile.
Usage:
To build the library and generate header (.di) files, run
---
rldc build
---
To build only the library file, run
---
rldc build lib
---
To only generate header files, run
---
rldc build headers
---
To make the documentation, run
---
rldc build html
---
Any command line arguments beyond the first one will be passed
on to the compiler. For example, to enable optimisations and
inlining when building the library, run
---
rldc build lib -O -inline
---
*/
import std.algorithm, std.array, std.exception, std.file, std.getopt, std.path,
std.process, std.stdio, std.string, std.zip;
/** Various build directories.
NOTE:
Running "build clean" will recursively and mercilessly
delete these directories. Make sure you don't use the current
directory, the root directory or any such thing. Preferably,
just leave them the way they are.
*/
version (Posix)
{
immutable libDir = "generated"; // Location of lib file
immutable headerDir = "generated/headers"; // Location of .di files
immutable htmlDir = "generated/html"; // Location of .html files
}
version (Windows)
{
immutable libDir = r"generated";
immutable headerDir = r"generated\headers";
immutable htmlDir = r"generated\html";
}
/** The name of the library. */
immutable libName = "scid";
/** The top-level directory of the source files. */
immutable srcDir = "scid";
int main(string[] args)
in { assert (args.length > 0); }
body
{
bool gdc;
string compiler = "ldc2";
getopt(args, std.getopt.config.passThrough, "gdc", &gdc);
if(gdc)
compiler = "gdmd";
try
{
if (args.length <= 1)
{
buildLib(compiler, null);
buildHeaders(compiler, null);
}
else if (args[1][0] == '-')
{
buildLib(compiler, args[1 .. $]);
buildHeaders(compiler, args[1 .. $]);
}
else if (args[1] == "lib") buildLib(compiler, args[2 .. $]);
else if (args[1] == "headers") buildHeaders(compiler, args[2 .. $]);
else if (args[1] == "html") buildHTML(compiler, args[2 .. $]);
else if (args[1] == "clean") builean();
else enforce(false, "Unknown command: " ~ args[1]);
return 0;
}
catch (Exception e)
{
stderr.writeln(e.msg);
return 1;
}
}
/** Build the library file. */
void buildLib(string compiler, string[] extraOptions)
{
ensureDir(libDir);
auto sources = getSources();
version (Posix) immutable libFile = "lib"~libName~".a";
version (Windows) immutable libFile = libName~".so";
immutable buimd = compiler ~ " "
~std.string.join(sources, " ")
~" -shared -soname "~ libFile~".1"~" -od"~libDir~" -of"~libFile~".1.0.0"
~" "~std.string.join(extraOptions, " ");
writeln(buimd);
enforce(system(buimd) == 0, "Error building library");
}
/** Generate header files. */
void buildHeaders(string compiler, string[] extraOptions)
{
ensureDir(headerDir);
auto sources = getSources();
foreach (s; sources)
{
immutable d = buildPath(headerDir, dirName(s));
stderr.writefln("%s + %s = %s", headerDir, dirName(s), d);
ensureDir(d);
immutable diName = baseName(s, ".d")~".di";
immutable cmd = compiler~" "~s~" -c -o- -H -Hd"~d~" -Hf"~diName
~" "~std.string.join(extraOptions, " ");
writeln(cmd);
enforce(system(cmd) == 0, "Error making header file: "~diName);
}
}
/** Build documentation. */
void buildHTML(string compiler, string[] extraOptions)
{
auto sources = getSources();
sort(sources);
ensureDir(htmlDir);
unzip("candydoc.zip", htmlDir);
string[] htmlFiles;
string moduleList = "MODULES =\n";
foreach (s; sources)
{
version (Posix) auto slash = "/";
version (Windows) auto slash = "\\";
htmlFiles ~= baseName(replace(s, slash, "_"),".d") ~ ".html";
// Do not list the scid.internal.* modules in the
// doc browser tree.
if (std.string.indexOf(s, "internal") == -1)
moduleList ~=
"\t$(MODULE "
~baseName(replace(s, slash, "."), ".d")
~")\n";
}
immutable modulesDdoc = buildPath(htmlDir, "candydoc", "modules.ddoc");
writeln("Writing "~modulesDdoc);
std.file.write(modulesDdoc, moduleList);
immutable candyDdoc = buildPath(htmlDir, "candydoc", "candy.ddoc");
foreach (i; 0 .. sources.length)
{
immutable cmd =
compiler~" "~sources[i]~" "~candyDdoc~" "~modulesDdoc
~" -c -o- -D -Dd"~htmlDir~" -Df"~htmlFiles[i]
~" "~std.string.join(extraOptions, " ");
writeln(cmd);
enforce(system(cmd) == 0, "Error making HTML file: "~htmlFiles[i]);
}
}
/** Remove build directories. */
void builean()
{
void rm(string path)
{
if (!exists(path)) return;
writeln("Removing: ", path);
if (isDir(path)) rmdirRecurse(path);
else std.file.remove(path);
}
rm(libDir);
rm(headerDir);
rm(htmlDir);
rm(__FILE__~".deps"); // Clean up after rldc as well
}
// Various utility functions
string[] getSources()
{
static string[] sources;
if (sources == null)
{
foreach (string f; dirEntries(srcDir, SpanMode.depth))
if (isFile(f) && extension(f) == ".d") sources ~= f;
}
return sources;
}
void ensureDir(string dir)
{
if (exists(dir)) enforce(isDir(dir), "Not a directory: "~dir);
else mkdirRecurse(dir);
}
void unzip(string zipFile, string toDir)
{
writeln("Unzipping "~zipFile~" to "~toDir);
auto zip = new ZipArchive(std.file.read(zipFile));
foreach (member; zip.directory)
{
if (member.name[$-1] == '/') continue; // Skip directory names
immutable f = buildPath(toDir, member.name);
ensureDir(dirName(f));
std.file.write(f, zip.expand(member));
}
}
scid deb packages available on:
https://code.google.com/p/d-apt/wiki/APT_Repository#APT_Repository_for_D
"d-apt" is an ATP repository to easily install/upgrade D binary packages on systems like Debian, Ubuntu, Linuxmint, etc.
Enjoy it!
...because in that case, the return value of the function is never actually used. See line 102 of nonlinear.d
.
SciD doesn't have any build in multidimensional minimization routines, which I (and probably others) could use. Because of this I recently wrote a library implementing differential evolution (BlackEdder/minimized). The API of this library is a bit simplistic, but it works. Would it be an idea to incorporate this into SciD? Maybe we should define a general interface for all minimization routines and have my library as one of the implementations?
interface Minimization(RANGE)
{
RANGE minimize(size_t maxIterations); // Perform minimization
void setFunction(double delegate(RANGE parameters) ; // Function to minimize
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.