Prev: Dhrystone
Next: Learning Ada
From: Simon Wright on
Ada novice <posts(a)gmx.us> writes:

>> You need special compilation options (-gnatpg) to allow compiling units
>> like these which (look as if they) are part of the standard
>> library. These options mean too that compilations have to be
>> warning-free.
>
> In GPS, I've taken a look at what switch is there for
> test_entionsions.gpr and I see -gnatqQ. Changing this to -gnatpg puts
> also -gnatVn automaticallt by GPS.

The idea is that -- whatever extra hoops -gnatpg makes you (me) go
through as a writer of Ada library components -- the ordinary user
needn't be worried.

>> > Note: for the source files adb and ads the name is ada-numerics-
>> > generic_complex_arrays-extensions. Should it be ada-numerics-
>> > generic_complex_arrays.extensions (with a dot between "arrays" and
>> > "extensions" instead)?
>
>> No, the dash is right:
>
>> ada-numerics-generic_complex_arrays-extensions
>> Ada.Numerics.Generic_Complex_Arrays.Extensions
>
> I raised this issue as in the ads and adb files, you wrote:
> Ada.Numerics.Generic_Complex_Arrays.Extensions .The dash is not
> present. When I copied the plain text files of the codes from SF to
> AdaGIDE, then of course, AdaGIDE proposed me the names
> Ada.Numerics.Generic_Complex_Arrays.Extensions which match the names
> inside the ads and adb files. But then I saw that on your website, you
> named them with the dash instead. If I understand correctly, should
> the names of the files not match the main procedure or package used
> inside an Ada file? Maybe I'm thinking wrong here.

See
http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_ugn_unw/File-Naming-Rules.html#File-Naming-Rules
for the details.
From: Ada novice on
Success here with the testing! Thanks for all your very kind help
Simon. First, I would like to draw your attention on 1 point. At
first, I was copying your raw files into AdaGIDE in order to save
them. Then running gnatmake -p -P test_extensions did produce a lots
of error messages: incorrect line terminator. I remember getting this
message before and what I did was to save the files in GPS and the
error messages disappear. I think in AdaGIDE pasting raw text can
cause some incompatibility due to the file system used. This is why I
guess I got this error: incorrect line terminator. I can't explain
this but I don't have it in GPS.


After successfully saving all your raw files within GPS, I ran
gnatmake -p -P test_extensions without any warnings/error messages and
the following were created:

A.) A lib folder is created at the same hierarchy level as src and
test. It has 2 files:
1.libada_math.dll
2.ada-numerics-generic_complex_arrays-extensions.ali


B.) In the src folder a .build folder is created with 2 files:
1. ada-numerics-generic_complex_arrays-extensions.ali
2. ada-numerics-generic_complex_arrays-extensions.o

C.) In the test folder a .build folder is created with 6 files:
1. b~test_extensions.adb
2. b~test_extensions.ads
3. b~test_extensions.ali
4. b~test_extensions.o
5. test_extensions.ali
6. test_extensions.o

Then I was able to build using Build main: test_extensions.adb
successfully.

Now for the outputs I get:

2.00000E+00 4.00000E+00
2.00000E+00 -4.00000E+00
9.99999E-01 1.10569E-07

-6.00000E+00
-4.00000E+00
-2.00000E+00
-1.21279E-07
2.00000E+00
4.00000E+00
6.00000E+00

6.00000E+00 0.00000E+00
4.00000E+00 0.00000E+00
-6.00000E+00 0.00000E+00
2.00000E+00 0.00000E+00
-3.17504E-07 0.00000E+00
-4.00000E+00 0.00000E+00
-2.00000E+00 0.00000E+00

The second set of results are for the Test16 which are ok. What about
the third set of results? What are these?


On Jul 31, 3:25 pm, Simon Wright <si...(a)pushface.org> wrote:

> The idea is that -- whatever extra hoops -gnatpg makes you (me) go
> through as a writer of Ada library components -- the ordinary user
> needn't be worried.
>

Here are the switches for "build main"

%gnatmake -q -c -gnats -u %eL -P%PP %X %fp

which are a bit similar to those you have in the jpg file from your
earlier post.

I didn't add -gnatpg for the compiler switch. I had these: -gnatqQ -
gnat05

and I can compile fine and output the results. Is the -gnatpg a
necessity?


Thanks very much for helping me with the compilation. Now it's good
that some more testing is done on different cases. Do you plan to add
the output for eigenvectors also?

YC



From: Simon Wright on
Ada novice <posts(a)gmx.us> writes:

> Success here with the testing! Thanks for all your very kind help
> Simon. First, I would like to draw your attention on 1 point. At
> first, I was copying your raw files into AdaGIDE in order to save
> them. Then running gnatmake -p -P test_extensions did produce a lots
> of error messages: incorrect line terminator. I remember getting this
> message before and what I did was to save the files in GPS and the
> error messages disappear. I think in AdaGIDE pasting raw text can
> cause some incompatibility due to the file system used. This is why I
> guess I got this error: incorrect line terminator. I can't explain
> this but I don't have it in GPS.

Was this perhaps with the ada-numerics* files? there may be some -gnatpg
problem with inconsistent line terminators, I guess GPS is clever enough
to know that it's going to be anuisance and fix it.

> After successfully saving all your raw files within GPS, I ran
> gnatmake -p -P test_extensions without any warnings/error messages and
> the following were created:
>
> A.) A lib folder is created at the same hierarchy level as src and
> test. It has 2 files:
> 1.libada_math.dll
> 2.ada-numerics-generic_complex_arrays-extensions.ali
>
> B.) In the src folder a .build folder is created with 2 files:
> 1. ada-numerics-generic_complex_arrays-extensions.ali
> 2. ada-numerics-generic_complex_arrays-extensions.o
>
> C.) In the test folder a .build folder is created with 6 files:
> 1. b~test_extensions.adb
> 2. b~test_extensions.ads
> 3. b~test_extensions.ali
> 4. b~test_extensions.o
> 5. test_extensions.ali
> 6. test_extensions.o
>
> Then I was able to build using Build main: test_extensions.adb
> successfully.

This looks as expected. NB that's a sort of half-baked library; to make
a proper dll * include files it needs to be a 'stand-alone library' in
GNAT terms. From the user's point of view it Just Works (I did have a
problem on a Debian machine with GCC 4.3.2, didn't automatically find
the shared library). Anyway, if it works for you on windows don't worry
about it!

> Now for the outputs I get:
>
> 2.00000E+00 4.00000E+00
> 2.00000E+00 -4.00000E+00
> 9.99999E-01 1.10569E-07
>
> -6.00000E+00
> -4.00000E+00
> -2.00000E+00
> -1.21279E-07
> 2.00000E+00
> 4.00000E+00
> 6.00000E+00
>
> 6.00000E+00 0.00000E+00
> 4.00000E+00 0.00000E+00
> -6.00000E+00 0.00000E+00
> 2.00000E+00 0.00000E+00
> -3.17504E-07 0.00000E+00
> -4.00000E+00 0.00000E+00
> -2.00000E+00 0.00000E+00
>
> The second set of results are for the Test16 which are ok. What about
> the third set of results? What are these?

The second set are with the package that comes with the compiler, that
takes a symmetric complex matrix (which this is - needs to be complex to
check the new code) and outputs a real eigenvalue vector.

The third set are with the new package, that takes a general complex
matrix and outputs a complex eigenvalue vector.

> I didn't add -gnatpg for the compiler switch. I had these: -gnatqQ -
> gnat05 and I can compile fine and output the results. Is the -gnatpg a
> necessity?

Yes *but only in the src/ directory*, which is why it's in
ada_math_build.gpr & not in test_extensions.gpr.

This is part of a clean compile...

gcc -c -g -fPIC -gnatpg -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/src/ada-numerics-generic_complex_arrays-extensions.adb
gcc -c -g -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/test/test_extensions.adb

and the first line, for the library, has the additional flags -fPIC
(because, on this architecture, you need position-independent code for a
shared library) and -gnatpg (from ada_math_build.gpr, as discussed).

> Thanks very much for helping me with the compilation. Now it's good
> that some more testing is done on different cases. Do you plan to add
> the output for eigenvectors also?

Seemed like a plan! Also real non-symmetric, I think.

I found the LAPACK test suite described here -
http://www.netlib.org/lapack/lawns/lawn41.ps - could be useful though it
could also be a pain to translate.
From: Ada novice on
On Jul 31, 11:02 pm, Simon Wright <si...(a)pushface.org> wrote:

> Was this perhaps with the ada-numerics* files? there may be some -gnatpg
> problem with inconsistent line terminators, I guess GPS is clever enough
> to know that it's going to be anuisance and fix it.

Once I had a similar problem with another adb or ads file which I got
from the web a few weeks back. Now I'm remembering that I had problem
with GPS and what I did afterwards was to save the "raw text" into
AdaGIDE and I didn't got any complain when compiling the file into
GPS. Is that because a raw text can be using a different end of line
marker? The file encoding that's being used in an editor maybe
different and not pure ASCII. In any case, one can always play around
and save the raw files in Notepad on Windows or in another editor like
WinEdt also.


> > I didn't add -gnatpg for the compiler switch. I had these: -gnatqQ -
> > gnat05 and I can compile fine and output the results. Is the -gnatpg a
> > necessity?
>
> Yes *but only in the src/ directory*, which is why it's in
> ada_math_build.gpr & not in test_extensions.gpr.
>
> This is part of a clean compile...
>
>    gcc -c -g -fPIC -gnatpg -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/src/ada-numerics-generic_complex_arrays-extensions.adb
>    gcc -c -g -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/test/test_extensions.adb
>
> and the first line, for the library, has the additional flags -fPIC
> (because, on this architecture, you need position-independent code for a
> shared library) and -gnatpg (from ada_math_build.gpr, as discussed).


Thanks for the explanation.


> > Thanks very much for helping me with the compilation. Now it's good
> > that some more testing is done on different cases. Do you plan to add
> > the output for eigenvectors also?
>
> Seemed like a plan! Also real non-symmetric, I think.
>
> I found the LAPACK test suite described here -http://www.netlib.org/lapack/lawns/lawn41.ps- could be useful though it
> could also be a pain to translate.

A long-term goal might perhaps be to be able to solve the generalized
eigenvalue problem. See for example here:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/eig.html

Now, the code has a function like (from the link above)

eig(A) returns a vector of the eigenvalues of matrix A.

In engineering, for example in vibration analysis, one is more
interested in the generalized eigenvalue problem (from the above link)

eig(A,B) returns a vector containing the generalized eigenvalues, if A
and B are square matrices.

In vibration analysis, matrices representing the mass, stiffness and
damping of a structure are readily formed from a model of the real-
life structure. When the generalized eigenvalue problem is solved,
then the eigenvalues give the resonances of the structure i.e.
frequencies at which large vibration occur. Normally only the first
few eigenvalues are of interest as they represent those resonant
frequencies that can give the most damage to the structure. The
corresponding eigenvectors represent then the relative displacements
between different locations of the structure at a given resonant
frequency and give a general idea how the structure is deformed at a
given resonant frequency (or eigenvalue). The eigenvectors don't give
the actual displacements but only an indication of how the different
parts of the structure will deform in relation to each other. Actual
magnitude of displacements can only be obtained under actual testing
when a force is applied to the structure.

Some information on the algorithm is found here in the IMSL C user
guide:

http://www.vni.com/products/imsl/documentation/CNL700_Docs/html/cmath/default.htm

in Chapter 2: Eigensystem analysis (on the left of the page and expand
the chapter to get the different sections) at the bottom of the
section "Usage notes", and in the sections eig_symgen, geneig and
genig (complex). But these are very complex algorithms. Your link to
lawn41.ps also has some information. And as you said, this can be a
pain to translate.


YC
From: Ada novice on
On Jul 31, 11:02 pm, Simon Wright <si...(a)pushface.org> wrote:

> Was this perhaps with the ada-numerics* files? there may be some -gnatpg
> problem with inconsistent line terminators, I guess GPS is clever enough
> to know that it's going to be anuisance and fix it.

Once I had a similar problem with another adb or ads file which I got
from the web a few weeks back. The problem was then with GPS and not
with AdaGIDE.
Now I'm remembering that I had problem
with GPS and what I did afterwards was to save the "raw text" into
AdaGIDE and I didn't got any complain when compiling the file into
GPS. Is that because a raw text can be using a different end of line
marker? The file encoding that's being used in an editor may be
different and not pure ASCII. In any case, one can always play around
and save the raw files in Notepad on Windows or in another editor like
WinEdt also.

> > I didn't add -gnatpg for the compiler switch. I had these: -gnatqQ -
> > gnat05 and I can compile fine and output the results. Is the -gnatpg a
> > necessity?

> Yes *but only in the src/ directory*, which is why it's in
> ada_math_build.gpr & not in test_extensions.gpr.

> This is part of a clean compile...

> gcc -c -g -fPIC -gnatpg -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/src/ada-numerics-generic_complex_arrays-extensions.adb
> gcc -c -g -gnatqQ -gnat05 -I- -gnatA /Users/simon/gnat-math-extn/test/test_extensions.adb

> and the first line, for the library, has the additional flags -fPIC
> (because, on this architecture, you need position-independent code for a
> shared library) and -gnatpg (from ada_math_build.gpr, as discussed).

Thanks for the explanation.

> > Thanks very much for helping me with the compilation. Now it's good
> > that some more testing is done on different cases. Do you plan to add
> > the output for eigenvectors also?

> Seemed like a plan! Also real non-symmetric, I think.

> I found the LAPACK test suite described here -http://www.netlib.org/lapack/lawns/lawn41.ps- could be useful though it
> could also be a pain to translate.

A long-term goal might perhaps be to be able to solve the generalized
eigenvalue problem. See for example here:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/eig.html

Now, the code has a function like (from the link above)

eig(A) returns a vector of the eigenvalues of matrix A.

In engineering, for example in vibration analysis, one is more
interested in the generalized eigenvalue problem (from the above link)

eig(A,B) returns a vector containing the generalized eigenvalues, if A
and B are square matrices.

In vibration analysis, matrices representing the mass, stiffness and
damping of a structure are readily formed from a model of the real-
life structure. When the generalized eigenvalue problem is solved,
then the eigenvalues give the resonances of the structure i.e.
frequencies at which large vibration occur. Normally only the first
few eigenvalues are of interest as they represent those resonant
frequencies that can give the most damage to the structure. The
corresponding eigenvectors represent then the relative displacements
between different locations of the structure at a given resonant
frequency and give a general idea how the structure is deformed at a
given resonant frequency (or eigenvalue). The eigenvectors don't give
the actual displacements but only an indication of how the different
parts of the structure will deform in relation to each other. Actual
magnitude of displacements can only be obtained under actual testing
when a force is applied to the structure.

Some information on the algorithm is found here in the IMSL C user
guide:

http://www.vni.com/products/imsl/documentation/CNL700_Docs/html/cmath...

in Chapter 2: Eigensystem analysis (on the left of the page and expand
the chapter to get the different sections) at the bottom of the
section "Usage notes", and in the sections eig_symgen, geneig and
genig (complex). But these are very complex algorithms. Your link to
lawn41.ps also has some information. And as you said, this can be a
pain to translate.

YC
First  |  Prev  |  Next  |  Last
Pages: 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Prev: Dhrystone
Next: Learning Ada