473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<&Arr ay2D<double>A> EV;

and dozens of other lines.

I think I'm missing something fundamental.

Thanks
Jim

Jul 22 '05 #1
10 3203
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<&Arr ay2D<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_inst ance.Eigenvalue (A);

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

SomeClass::Eige nvalue(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<&Arr ay2D<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_inst ance.Eigenvalue (A);

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

SomeClass::Eige nvalue(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(cons t TNT::Array2D<Re al> &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::Eigenval ue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(con st TNT::Array2D<Re al>&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<&Arr ay2D<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_inst ance.Eigenvalue (A);

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

SomeClass::Eige nvalue(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(cons t TNT::Array2D<Re al> &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::Eigenval ue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(con st TNT::Array2D<Re al>&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<&Arr ay2D<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_inst ance.Eigenvalue (A);

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

SomeClass::Eige nvalue(A);

-Kevin


Jul 22 '05 #5

"jim.brown" <ji*******@mind spring.com> wrote in message
news:40******** ******@mindspri ng.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(cons t TNT::Array2D<Re al> &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<doub le> 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*******@mind spring.com> wrote in message
news:40******** ******@mindspri ng.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(cons t TNT::Array2D<Re al> &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<doub le> 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*******@mind spring.com> wrote in message
news:40******** ******@mindspri ng.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(cons t TNT::Array2D<Re al> &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<doub le> 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*******@mind spring.com> wrote in message
news:40******** ******@mindspri ng.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(cons t TNT::Array2D<Re al> &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<doub le> 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(cons t TNT::Array2D<Re al> &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<Typ e> vec);

and this:

template <class Type> void Func(vector<Typ e> 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::Eigenval ue: class has no constructors"

If I say
Eigenvalue(
The MS VC7 Compiler prompts me with
"Eigenvalue(con st TNT::Array2D<Re al>&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<doub le> my_eigenvalue(m y_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

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

Similar topics

7
9277
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. # No warranty express or implied for the accuracy, fitness to purpose
3
1964
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> <a/><a/><b/><a><a><a><b/><a><b/><a><a>
10
453
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 says that the is the public method: Eigenvalue (const TNT::Array2D< Real > &A) I write this program
1
3963
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 size n. There are n!/(s!(n-s)!) ways to do this. Donald E. Knuth gives several methods (algorithms) to generate all the s-combinations in . In such procedure-oriented way, each s-combination is processed while it's being generated. In some
2
2815
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, messages, etc: // If this parameter is NULL, // GetModuleHandle returns a handle of the file used // to create the calling process. hInstExe = GetModuleHandle( NULL ); if( hInstExe!=NULL )
26
2875
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: error: using obsolete binding at 'j'
36
3018
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 get this kind of inconsistent result. -- ----------------------------------------------------------------------------- | Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
7
3025
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 that displays the result of a VB.Net function that uses a value from an existing column I have spent 4 hours trying to do this after Googling for examples... There are many new concepts that I haven't had much experience with...
1
1583
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, not sure to use apply-templates or call-templates. Trying to find good examples on both w/ the main file and source file, but have it a road block. Does anyone have ideas on this or good xsl sites that I can refer too. ~thanks!
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.