Code Monkey home page Code Monkey logo

scid's People

Contributors

9il avatar aleixgg avatar blackedder avatar bolpat avatar john-colvin avatar kyllingstad avatar martinnowak avatar thewilsonator avatar webdrake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scid's Issues

Publish new release for DMD's CI

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.

Constants

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:

  1. Put information about the system of units to module name
  2. Group similar constants like Planck's h and h with bar inside one enum, e.g. in CGS PLANCK.H = 6.6...e-27, PLANCK.HBAR = = 1.0...e-27
  3. Uncertainty value (if any) should have the same name as the magnitude has with a special prefix/postfix (what should it be?)
  4. Group constants in the following modules:
    • fundamental - universal constants like Planck's constant, speed of light, elementary charge etc. and combinations of them like fine-structure constant
    • additional - constants like Bohr radius that are not pure combination of fundamental constants (e.g. depend on mass of electron) but are usually not considered as characteristics of particles or unit conversion coefficients
    • particles - characteristics of elementary particles: masses, magnetic moments etc.
    • what else?
  5. Add separate modules containing constants in different systems of units (SI, CGS, ...) i.e. the full module name would be scid.constants.cgs.fundamental
  6. Add a module containing coefficients to convert magnitudes between different measuring units
    • The module would consist of enum's which names would be the names of units and members - values of the units in terms of other units e.g. METER.ANGSTROM = 1e+10

By the way, should the names of constants be in CAPITAL letters?

What do you think about this?

ScientificD

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?

Extend MatrixView API with overloaded operators

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.

installation / usage issues

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:

  1. upgraded to dmd v2.066.1
  2. built and installed https://github.com/9il/cblas, i.e.
    2.1 dub build => libcblas.a
    2.2. mv libcblas.a /usr/local/lib/ (where libphobos2.a lives for me)
  3. built and installed scid, i.e.
    3.1 unzip, then cd source/scid/bindings/blas
    3.2 symlink to cblas.d: ln -s path/to/cblas-master/source/cblas/cblas.d
    3.3 rdmd build -O [switch -inline made compilation fail with errors]
    => generated/libscid.a
    => generated/headers/... (including source/scid/bindings/blas/cblas.di, so I am guessing cblas worked)
    3.4 mv generated/headers/source/scid /usr/local/include/dmd2/ (where phobos & druntime live)
    mv generated/libscid.a /usr/local/lib/ (where libphobos2.a lives)
    3.5 added flags "-I/usr/local/include/dmd2" and "-L/usr/local/lib" to DFLAGS in dmd.conf so that dmd finds /usr/local/include/dmd2/scid and the libraries.
  4. In a source file main.d, used:
    import scid.linalg;
    import scid.matrix;
    ...
    auto m = matrix!double(2, 2);
    // filling it m[0,0]=1.0; etc.
    auto d = det(m);
  5. compiled with:
    dmd -L-lscid -L-llapack main.d

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!

Build script should allow choice of compiler

If I understand correctly, the current build script hardcodes in dmd as the compiler. This is undesirable for a couple of reasons.

  • gdc produces much faster code, so if you're in a position to compile with gdc this is preferable :-)
  • Some Linux distros (e.g. Debian) have strict rules about proprietary dependencies; a reliance on dmd will block packaging of SciD. Of course, it's trivial to manually tweak the build script, but nicer to make it so they don't have to.
  • ... related: it's not clear to me that the build script allows you to set optimization flags. This would be nice to have as well.

build.d able to build as sharedlib with ldc 2

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
 }

Allow for inverting a complex matrix

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?

Change licence to MPL 2.0

This will allow people to use SciD in proprietary applications, while preventing them from releasing proprietary versions of the library itself.

building docs makes complaints

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.

build.d able to build as sharedlib with ldc 2

#!/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));
    }
}

multidimensional minimization is missing

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.