473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Example of calling JAMA which uses TNT templates

Please refer me to the right place if this is the wrong place to post
this question.

I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation says that the is the public method:

Eigenvalue (const TNT::Array2D< Real > &A)

I write this program

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;

(which all works fine)
But then I can't figure out how to call the Eigenvalue routine.
I'm sure this is a C++ Template question not a JAMA or TNT
question. Here's what I tried:

Eigenvalue<&Array2D<double>A> EV;

and dozens of other lines.

I think I'm missing something fundamental.

Thanks
Jim

Jul 22 '05 #1
10 3171
jim.brown wrote:
Please refer me to the right place if this is the wrong place to post
this question.

I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation says that the is the public method:
By "public method" do you mean this is a member function of some class?
If so, what class?

Eigenvalue (const TNT::Array2D< Real > &A)

I write this program

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
First obvious problem is that 'Real' may not be the same type as
'double' (since we don't know anything about 'Real'). Maybe you should
declare 'A' as Array2D<Real>.

(which all works fine)
But then I can't figure out how to call the Eigenvalue routine.
I'm sure this is a C++ Template question not a JAMA or TNT
question. Here's what I tried:

Eigenvalue<&Array2D<double>A> EV;


This appears to be complete nonsense. Eigenvalue is a function, right?
So you call it just like any other function, with the name then the
arguments in parenthesis:

Eigenvalue(A);

If it is a member function, you'll need to specify an instance of the
class to use, like so:

some_class_instance.Eigenvalue(A);

Unless it is a static member function, in which case you can do it
without an instance, this way:

SomeClass::Eigenvalue(A);

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #2
jim.brown wrote:
Please refer me to the right place if this is the wrong place to post
this question.

I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation says that the is the public method:
By "public method" do you mean this is a member function of some class?
If so, what class?

Eigenvalue (const TNT::Array2D< Real > &A)

I write this program

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
First obvious problem is that 'Real' may not be the same type as
'double' (since we don't know anything about 'Real'). Maybe you should
declare 'A' as Array2D<Real>.

(which all works fine)
But then I can't figure out how to call the Eigenvalue routine.
I'm sure this is a C++ Template question not a JAMA or TNT
question. Here's what I tried:

Eigenvalue<&Array2D<double>A> EV;


This appears to be complete nonsense. Eigenvalue is a function, right?
So you call it just like any other function, with the name then the
arguments in parenthesis:

Eigenvalue(A);

If it is a member function, you'll need to specify an instance of the
class to use, like so:

some_class_instance.Eigenvalue(A);

Unless it is a static member function, in which case you can do it
without an instance, this way:

SomeClass::Eigenvalue(A);

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #3
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {

You are right that the example I posted is nonsense but I had tried
other obvious calls as you suggest. If I understand templates
(and I don't much), Real is the type paramater to the template.
I should be able to instantiate a "double" version of this template.

If I try
Eigenvalue (A);
I get "A unknown size"

If I say
new Eigenvalue( A );
I get "JAMA::Eigenvalue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(const TNT::Array2D<Real>&A)"

I'm completely lost. JAMA and TNT are publicly available codes
and I have to believe they are well defined. I just don't know
how to call them.

Thanks again for the help

Jim
Kevin Goodsell wrote:
jim.brown wrote:
Please refer me to the right place if this is the wrong place to post
this question.

I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation says that the is the public method:

By "public method" do you mean this is a member function of some class?
If so, what class?

Eigenvalue (const TNT::Array2D< Real > &A)

I write this program

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;

First obvious problem is that 'Real' may not be the same type as
'double' (since we don't know anything about 'Real'). Maybe you should
declare 'A' as Array2D<Real>.

(which all works fine)
But then I can't figure out how to call the Eigenvalue routine.
I'm sure this is a C++ Template question not a JAMA or TNT
question. Here's what I tried:

Eigenvalue<&Array2D<double>A> EV;

This appears to be complete nonsense. Eigenvalue is a function, right?
So you call it just like any other function, with the name then the
arguments in parenthesis:

Eigenvalue(A);

If it is a member function, you'll need to specify an instance of the
class to use, like so:

some_class_instance.Eigenvalue(A);

Unless it is a static member function, in which case you can do it
without an instance, this way:

SomeClass::Eigenvalue(A);

-Kevin


Jul 22 '05 #4
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {

You are right that the example I posted is nonsense but I had tried
other obvious calls as you suggest. If I understand templates
(and I don't much), Real is the type paramater to the template.
I should be able to instantiate a "double" version of this template.

If I try
Eigenvalue (A);
I get "A unknown size"

If I say
new Eigenvalue( A );
I get "JAMA::Eigenvalue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(const TNT::Array2D<Real>&A)"

I'm completely lost. JAMA and TNT are publicly available codes
and I have to believe they are well defined. I just don't know
how to call them.

Thanks again for the help

Jim
Kevin Goodsell wrote:
jim.brown wrote:
Please refer me to the right place if this is the wrong place to post
this question.

I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation says that the is the public method:

By "public method" do you mean this is a member function of some class?
If so, what class?

Eigenvalue (const TNT::Array2D< Real > &A)

I write this program

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;

First obvious problem is that 'Real' may not be the same type as
'double' (since we don't know anything about 'Real'). Maybe you should
declare 'A' as Array2D<Real>.

(which all works fine)
But then I can't figure out how to call the Eigenvalue routine.
I'm sure this is a C++ Template question not a JAMA or TNT
question. Here's what I tried:

Eigenvalue<&Array2D<double>A> EV;

This appears to be complete nonsense. Eigenvalue is a function, right?
So you call it just like any other function, with the name then the
arguments in parenthesis:

Eigenvalue(A);

If it is a member function, you'll need to specify an instance of the
class to use, like so:

some_class_instance.Eigenvalue(A);

Unless it is a static member function, in which case you can do it
without an instance, this way:

SomeClass::Eigenvalue(A);

-Kevin


Jul 22 '05 #5

"jim.brown" <ji*******@mindspring.com> wrote in message
news:40**************@mindspring.com...
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {


That's not a method, its the constructor, it has the same name as the class.

Start like this

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
Eigenvalue<double> some_object(A);

Which creates an Eigenvalue object (called some_object) using the
constructor you mentioned.

How that relates to calculating the Eigen value is something you'll have to
go back to your documentation for.

john
Jul 22 '05 #6

"jim.brown" <ji*******@mindspring.com> wrote in message
news:40**************@mindspring.com...
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {


That's not a method, its the constructor, it has the same name as the class.

Start like this

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
Eigenvalue<double> some_object(A);

Which creates an Eigenvalue object (called some_object) using the
constructor you mentioned.

How that relates to calculating the Eigen value is something you'll have to
go back to your documentation for.

john
Jul 22 '05 #7
This filled in the missing piece. Many thanks. I have it running now.
I appreciate your taking the time to post your reply.
Jim

John Harrison wrote:
"jim.brown" <ji*******@mindspring.com> wrote in message
news:40**************@mindspring.com...
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {

That's not a method, its the constructor, it has the same name as the class.

Start like this

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
Eigenvalue<double> some_object(A);

Which creates an Eigenvalue object (called some_object) using the
constructor you mentioned.

How that relates to calculating the Eigen value is something you'll have to
go back to your documentation for.

john


Jul 22 '05 #8
This filled in the missing piece. Many thanks. I have it running now.
I appreciate your taking the time to post your reply.
Jim

John Harrison wrote:
"jim.brown" <ji*******@mindspring.com> wrote in message
news:40**************@mindspring.com...
Many thanks for the reply. I've supplied more information.

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {

That's not a method, its the constructor, it has the same name as the class.

Start like this

Array2D<double> A(3,3);
A[0][0] = 10.; A[0][1] = 0.; A[0][2] = 0.;
A[1][0] = 0.; A[1][1] = 20.; A[1][2] = 0.;
A[2][0] = 0.; A[2][1] = 0.; A[2][2] = 50.;
Eigenvalue<double> some_object(A);

Which creates an Eigenvalue object (called some_object) using the
constructor you mentioned.

How that relates to calculating the Eigen value is something you'll have to
go back to your documentation for.

john


Jul 22 '05 #9
jim.brown wrote:
Many thanks for the reply. I've supplied more information.
Please don't top-post. Read section 5 of the FAQ for posting guidelines.

http://www.parashift.com/c++-faq-lite/

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {
OK, that's quite a bit different from what I was expecting, so my reply
is not accurate. In the future you might want to give more context when
asking a question.

As John said, this is a constructor for the class. How you use the class
to extract the actual eigenvalues is unknown to us -- check the docs.

You are right that the example I posted is nonsense but I had tried
other obvious calls as you suggest. If I understand templates
(and I don't much), Real is the type paramater to the template.
I should be able to instantiate a "double" version of this template.
That's right, but the code snippets in your first post suggested that
Eigenvalue was a function taking a specialization of Array2d for an
unknown type 'Real'. There's a big difference between this:

void Func(vector<Type> vec);

and this:

template <class Type> void Func(vector<Type> vec);

You gave the former, while in reality Eigenvalue() is closer to the latter.

If I try
Eigenvalue (A);
I get "A unknown size"

If I say
new Eigenvalue( A );
I get "JAMA::Eigenvalue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(const TNT::Array2D<Real>&A)"
Eigenvalue is a class [template], so you actually want to create an
instance (probably -- it's also possible that you might want to use
static members of Eigenvalue, in which case an instance is not
required), and you probably want to initialize it (via the constructor
above) with an Array2d object:

Eigenvalue<double> my_eigenvalue(my_array2d);

I'm completely lost. JAMA and TNT are publicly available codes
and I have to believe they are well defined. I just don't know
how to call them.


That's about as far as we can help. The rest has to do with details of
the library. If the docs aren't helpful, you might see if there's a
forum or mailing list for those libraries and seek help there. Or search
the web, or examine the source code and see if you can figure it out
yourself.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #10
jim.brown wrote:
Many thanks for the reply. I've supplied more information.
Please don't top-post. Read section 5 of the FAQ for posting guidelines.

http://www.parashift.com/c++-faq-lite/

Here is the template definition of Eigenvalue in namespace JAMA.

template <class Real>
class Eigenvalue
{

The method I'm tring to call is a public method in class Eigenvalue
with this header.

Eigenvalue(const TNT::Array2D<Real> &A) {
OK, that's quite a bit different from what I was expecting, so my reply
is not accurate. In the future you might want to give more context when
asking a question.

As John said, this is a constructor for the class. How you use the class
to extract the actual eigenvalues is unknown to us -- check the docs.

You are right that the example I posted is nonsense but I had tried
other obvious calls as you suggest. If I understand templates
(and I don't much), Real is the type paramater to the template.
I should be able to instantiate a "double" version of this template.
That's right, but the code snippets in your first post suggested that
Eigenvalue was a function taking a specialization of Array2d for an
unknown type 'Real'. There's a big difference between this:

void Func(vector<Type> vec);

and this:

template <class Type> void Func(vector<Type> vec);

You gave the former, while in reality Eigenvalue() is closer to the latter.

If I try
Eigenvalue (A);
I get "A unknown size"

If I say
new Eigenvalue( A );
I get "JAMA::Eigenvalue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(const TNT::Array2D<Real>&A)"
Eigenvalue is a class [template], so you actually want to create an
instance (probably -- it's also possible that you might want to use
static members of Eigenvalue, in which case an instance is not
required), and you probably want to initialize it (via the constructor
above) with an Array2d object:

Eigenvalue<double> my_eigenvalue(my_array2d);

I'm completely lost. JAMA and TNT are publicly available codes
and I have to believe they are well defined. I just don't know
how to call them.


That's about as far as we can help. The rest has to do with details of
the library. If the docs aren't helpful, you might see if there's a
forum or mailing list for those libraries and seek help there. Or search
the web, or examine the source code and see if you can figure it out
yourself.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
3
by: Erhard Schwenk | last post by:
Hi there, Maybe this is a faq, if so, point me the URL please. I have to do some xml to xml transformations in xslt, where I have - simplified - the following: input: <doc>...
10
by: jim.brown | last post by:
Please refer me to the right place if this is the wrong place to post this question. I'm looking for an example of calling the Eigenvalue routines of JAMA from a C++ program. The documentation...
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
2
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors,...
26
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37:...
36
by: phil-news-nospam | last post by:
Here is a simpler (no drop shadows) example of the padding bug I see: http://phil.ipal.org/usenet/ciwas/2006-05-08/buttons-1.html So far I find nothing in the CSS2 document that says I should...
7
by: Mark B | last post by:
Can someone write some VB.Net example code for me that does this: 1) Creates a gridview control with the results of a SQL stored procedure that has 1 parameter (text) 2) Adds an extra column...
1
by: stepthom | last post by:
I am attempting to break my templates down from 1 main xsl file into smaller files. Then I want to call them from a main xsl file. I started to look. I have found xsl:include and xsl:import. Also,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.