Jump to page: 1 2 3
Thread overview
library to solve the system of linear equations
Oct 14, 2022
Yura
Oct 14, 2022
Ben Jones
Oct 14, 2022
M.M.
Oct 14, 2022
Sergey
Oct 14, 2022
Yura
Oct 15, 2022
Sergey
Oct 15, 2022
Siarhei Siamashka
Oct 17, 2022
Yura
Oct 17, 2022
mw
Oct 18, 2022
Siarhei Siamashka
Oct 18, 2022
mw
Oct 18, 2022
Yura
Oct 26, 2022
Yura
Oct 26, 2022
Yura
Oct 26, 2022
Yura
Oct 17, 2022
jmh530
Oct 17, 2022
mw
Oct 17, 2022
rikki cattermole
Oct 17, 2022
mw
Oct 18, 2022
Siarhei Siamashka
Oct 15, 2022
Siarhei Siamashka
October 14, 2022

Dear All,

I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler.

At the moment I need to solve the system of liner equations:

A00q0 + A01q1 + A02q2 ... = -V0
A10
q0 + A11q1 + A12q2 ... = -V1
...

I have all my Aij coefficients in the double [][] A array, and V numbers in the array double [] b.

Is there any quick D solution for it? Something like in python one can do:

numpy.linalg.solve(a,b) ?

Quick web search revealed a few scientific libraries for D like Mir or lubek.

I am working under Ubuntu 18.04 and compiling my code like " gdc solv.d"

Could someone please provide a quick d solution for this, including details on how to install the library & link it to the code? I do not need anything advanced, just the easiest option.

I am sorry for too basic question, just want to check my idea quickly. Thank you!

October 14, 2022

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

>

...

Check out MIR https://github.com/libmir

October 14, 2022

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

>

Dear All,

I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler.

[...]

Did not try it, but the example for the function luSolve at the lubeck documentation website should be helpful:

https://lubeck.dpldocs.info/v1.5.1/kaleidic.lubeck.luSolve.html

October 14, 2022

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

>

Dear All,

I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler.

At the moment I need to solve the system of liner equations:

A00q0 + A01q1 + A02q2 ... = -V0
A10
q0 + A11q1 + A12q2 ... = -V1
...

Could someone please provide a quick d solution for this, including details on how to install the library & link it to the code? I do not need anything advanced, just the easiest option.

I am sorry for too basic question, just want to check my idea quickly. Thank you!

Firstly I will suggest to install dub - the D package manager. It will be easier to isntall other libraries using it.

Install openblas in your Ubuntu system. After that you can create a new folder and type in terminal

dub init

The main part will be about "dependencies". Type "lubeck".
After that you could check the example of the simple program here:
https://github.com/kaleidicassociates/lubeck/blob/master/example/source/app.d

It is exactly solving simple system of linear equations.
Link to the package where you can find additional details and documentation: https://code.dlang.org/packages/lubeck

October 14, 2022

On Friday, 14 October 2022 at 18:37:00 UTC, Sergey wrote:

>

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

>

Dear All,

I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler.

At the moment I need to solve the system of liner equations:

A00q0 + A01q1 + A02q2 ... = -V0
A10
q0 + A11q1 + A12q2 ... = -V1
...

Could someone please provide a quick d solution for this, including details on how to install the library & link it to the code? I do not need anything advanced, just the easiest option.

I am sorry for too basic question, just want to check my idea quickly. Thank you!

Firstly I will suggest to install dub - the D package manager. It will be easier to isntall other libraries using it.

Install openblas in your Ubuntu system. After that you can create a new folder and type in terminal

dub init

The main part will be about "dependencies". Type "lubeck".
After that you could check the example of the simple program here:
https://github.com/kaleidicassociates/lubeck/blob/master/example/source/app.d

It is exactly solving simple system of linear equations.
Link to the package where you can find additional details and documentation: https://code.dlang.org/packages/lubeck

Thank you!

First, I installed dub on Linux. Then I installed both libopenblas-dev and libopenblas-base.
After that I tried to initiate a new project via dub init. I tried to use the following dependency:
"mir-algorithm". After I got dub.sdl file that contains at the end line:

dependency "mir-algorithm" version="~>3.16.12"

in the top of my el.d file I have:
/+dub.sdl:
dependency "mir-algorithm" version="~>3.16.12"
+/
import std.stdio;
import std.string;
import std.conv;
import std.exception : assertThrown;
import std.math;
import mir.ndslice;

however, when I try to compile it (gdc el.d) it gives me the following error message:

el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' which cannot be read
import mir.ndslice;
^
import path[0] = /usr/lib/gcc/x86_64-linux-gnu/8/include/d

What am I doing wrong? Should I specify the library upon compilation?

I am sorry, I am feeling I am asking too basic question.

Thank you!

October 15, 2022

On Friday, 14 October 2022 at 21:38:45 UTC, Yura wrote:

>

On Friday, 14 October 2022 at 18:37:00 UTC, Sergey wrote:
however, when I try to compile it (gdc el.d) it gives me the following error message:

el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' which cannot be read
import mir.ndslice;
^
import path[0] = /usr/lib/gcc/x86_64-linux-gnu/8/include/d

What am I doing wrong? Should I specify the library upon compilation?

I am sorry, I am feeling I am asking too basic question.

Thank you!

Did you try to use 'dub build'?
You should run it in the same folder where dub.sdl is located.
Also maybe you will have to specify compiler in dub:

dub build --compiler=gdc

Some details about DUB you could find here https://dub.pm/

October 15, 2022

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

>

I am working under Ubuntu 18.04 and compiling my code like "gdc solv.d"

That's an old distribution released 4 years ago and already approaching its End of Standard Support in a few months (April 2023). This distribution offers old versions of D compilers too:

  • LDC 1.8.0-1 (compatible with old DMD 2.078)
  • GDC 8.3.0-1ubuntu2.3 (compatible with old DMD 2.068)

If you are really forced to choose between these two, then LDC is likely a better option. You can probably also install DMD from Snap Store: https://snapcraft.io/install/dmd/ubuntu

October 15, 2022

On Friday, 14 October 2022 at 21:38:45 UTC, Yura wrote:

>

in the top of my el.d file I have:

/+dub.sdl:
dependency "mir-algorithm" version="~>3.16.12"
+/
import std.stdio;
import std.string;
import std.conv;
import std.exception : assertThrown;
import std.math;
import mir.ndslice;

however, when I try to compile it (gdc el.d) it gives me the following error message:

el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' which cannot be read
import mir.ndslice;

This all looks good, except for the "gdc el.d" part. A small application contained in a single .d file can be run like a script via "dub el.d". This is explained at https://dub.pm/advanced_usage.html

For compiling highly optimized final binaries you can run "dub build --build=release --single --compiler=ldc2 el.d" (to use LDC) or "dub build --build=release --single --compiler=gdc el.d" (to use GDC).

October 17, 2022

Dear All, Thank you so much for your replies and hints! I got it working today. All the libraries are properly linked and the Equation solver runs smoothly.

The compilers turned out to be problematic though. The "Mir" library does not work with the Ubuntu 18.04 gdc and ldc compilers. I have managed to install the latest version dmd, and it works. But I suspect that the dmd compiler is not optimal in terms of performance. The question becomes whether it is possible to install the most recent ldc and gdc compilers on Ubuntu 18.04?

The good thing is that I have also managed to get this code working in parallel.

Thank you again!

On Saturday, 15 October 2022 at 13:11:04 UTC, Siarhei Siamashka wrote:

>

On Friday, 14 October 2022 at 21:38:45 UTC, Yura wrote:

>

in the top of my el.d file I have:

/+dub.sdl:
dependency "mir-algorithm" version="~>3.16.12"
+/
import std.stdio;
import std.string;
import std.conv;
import std.exception : assertThrown;
import std.math;
import mir.ndslice;

however, when I try to compile it (gdc el.d) it gives me the following error message:

el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' which cannot be read
import mir.ndslice;

This all looks good, except for the "gdc el.d" part. A small application contained in a single .d file can be run like a script via "dub el.d". This is explained at https://dub.pm/advanced_usage.html

For compiling highly optimized final binaries you can run "dub build --build=release --single --compiler=ldc2 el.d" (to use LDC) or "dub build --build=release --single --compiler=gdc el.d" (to use GDC).

October 17, 2022

On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote:

>

it is possible to install the most recent ldc and gdc compilers on Ubuntu 18.04?

Yes, I used LDC on the same system.

« First   ‹ Prev
1 2 3