473,378 Members | 1,383 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,378 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 3174
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.