• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Arcane Computer Help Needed Desperately

Vorticity

Fluid Mechanic
Joined
Apr 4, 2002
Messages
2,677
I normally wouldn't bother the folks here with this, but I've been struggling with this problem for days, and it's driving me mad. I figured some of the computer gurus here might be able to help me. Keep in mind while reading this that I am a bare beginner in just about everything you can think of related to this.

I have (very, very) rudimentary C++ programming skills, and I've been using them to write some code to perform some numerics for my research. Lately, I have an application that requires a lot of linear algebra (find eigenvalues, Cholesky decompositions, etc. Never mind if you don't know what that stuff is, it's not important.). There exists a package of C++ routines for all of this called lapack++. I've been struggling for a long time trying to install some version of this on my machine, and make it work.

My understanding is that lapack++ should consist of a bunch of "header files" that contain definitions of functions (I have a vague idea of what a "header file" is.)

1) I'm running Windows ME (I know, I know...)
2) To compile my C++ code, I use Microsoft Visual Studio 6.0 (I know, I know...). I have no idea how to use the "command line compiler". I only found out what a "command line compiler" was recently.

Info about lapack++ can be found at the following locations (to name a few, there are many, see Google):

http://math.nist.gov/lapack++/
http://www.netlib.org/lapack++/

Almost universally, all info and versions of lapack++ online assume you are using Unix/Linux. I, alas, am not. There are a few implementations you can download that claim[\i] to be for Windows, but often the documentation is still written for Unix.

There are some implementations of lapack++ for windows at various sites, for example:

http://sourceforge.net/projects/lapackpp

I downloaded the "setup.exe" from the "download" link on this site. I let it do its setup, but nothing special happened when it was done. No lapack++ functions became available. Then the guessing began. I took all of the ".h" files that came with it and put them in the directory with all of the other .h files that Microsoft Visual Studio uses. Nothing happens when I include the "lapack++.h" header. Just a lot of errors.

I'm absolutely baffled. Most versions of lapack++ online either require you to have a fortran compiler for some arcane purpose (I don't have one), or they require you to "make" a file (I don't know what that means or how to do it. Isn't it a Unix thing?). Even if I had a fortran compiler and all of that, I'd have no clue what to do with it.

So can anyone here help me? I need some step-by-step instructions that explain at a rudimentary two-year-old level how to make any of the lapack++ packages from online go.

Thanks very, very much for any help.
 
Well, I found this: http://sourceforge.net/users/cstim/

He's the admin for the project, you can contact him from that page if you have a question.

However, I think it's only been tested with specific compilers, and from what I can tell of the documentation you need a Fortran compiler and the earlier version (Lapack, without the ++). You might need to download just the source and compile, or even compile in Linux and then copy, I really don't know. It also just might not work with MS Visual Studio (again, I dunno)

There are links on the project page to mailing lists, but again I don't know if they would be helpful.
 
It requires FORTRAN because a lot of that old stuff is written in FORTRAN.

You could also get a copy of a book called Numerical Recipes in C. The translations aren't very good, being fairly simple-minded translations from FORTRAN, but they do work.
 
First, any reason you aren't using TNT, which is the successor to this package? You are facing difficulties trying to use a package which is no longer supported. TNT has the advantage of everything being in header files, and thus you don't have to compile the TNT code, just your own. Of course (and this won't be apparent to you until you encounter them) the error messages are going to be bloody horrific to read.

What you are trying to do is pretty complicated, and you are unlikely to get step-by-step instructions, because it is far from simple to change a bunch of code and makefiles (makefiles tell the compiler how to automatically build the code) from unix and unix compilers to windows and a microsoft compiler. A quick look shows some unix specific function calls, as well as header files that are not supplied with windows.

The TNT code looks MUCH nicer. All you will need to do is put it in some directory (say c:\TNT), and then tell your compiler to look in c:\TNT for the header files. In VC 6.0, you can do this from the properties menu of the project (look for something called additional include directories) or with the command line compiler you will need to use a compile line option such as -I"c:\TNT" (I don't think that is the right syntax for microsoft compiler).

Anyway, if this was my project, I'd recoil from lapack in horror, and start with TNT.
 
Re: Re: Arcane Computer Help Needed Desperately

epepke said:
It requires FORTRAN because a lot of that old stuff is written in FORTRAN.

You could also get a copy of a book called Numerical Recipes in C. The translations aren't very good, being fairly simple-minded translations from FORTRAN, but they do work.
I actually have a copy of that very book. Unfortunately, it doesn't contain quite the utility I need. I need to find the Eigenvalues of a very large, symmetric matrix. I don't need the eigenvectors. Num Rec in C only has the eigenvalues + eigenvectors code. Too slow.

Thanks, though.
 
roger said:
First, any reason you aren't using TNT, which is the successor to this package? You are facing difficulties trying to use a package which is no longer supported. TNT has the advantage of everything being in header files, and thus you don't have to compile the TNT code, just your own. Of course (and this won't be apparent to you until you encounter them) the error messages are going to be bloody horrific to read.
...
Thanks! I have just downloaded TNT, and will begin to play with it to see if my small mind can make it work.

Do you know if this package contains a utility for computing all the eigenvalues of an extremely large, real, symmetric matrix, without also finding the eigenvectors?
 
I remember doing this stuff at one point in college, but I've mercifully seemed to killed off all the relevant neurons with beer. However, I suspect thatthis gives you what you need.
 
roger said:
I remember doing this stuff at one point in college, but I've mercifully seemed to killed off all the relevant neurons with beer. However, I suspect thatthis gives you what you need.

Thanks! Coincidentally, I had that very page open in another window when you posted that.

By the way, do you (or anybody here) have any idea how big of a matrix is too big to do things like compute the eigenvalues, do a cholesky decomposition, etc.? In other words, if I have an NxN matrix, and I want to do this kind of thing, will, say, N=1000 take six years, six days, six minutes? How big is too big? I really have no idea.

I'm dealing with matrices with N possibly as high as 12,000.
 
Vorticity said:
I'm dealing with matrices with N possibly as high as 12,000.

As far as I know, this is still at the Research Project phase. It's basically the same thing that economists do, and they have pretty much resolved themselves to approximations. Sorry; not good news. But you might want to look at some of the economics literature. Also, this kind of thing is amenable to calculation using graphics processing units (GUPs). If you have a recent Radeon or GeForce graphics card, you might be able to speed up your processing. This, however, requires some tricky coding.
 
epepke said:
Also, this kind of thing is amenable to calculation using graphics processing units (GUPs). If you have a recent Radeon or GeForce graphics card, you might be able to speed up your processing. This, however, requires some tricky coding.

Ick, yeah. That's terribly complicated coding that probably won't make it much faster. If you need to do some serious processing, it's probably a good idea to write whatever you need with cross-platform compatibility in mind, then get some time on a real multi-processor Unix server.
 
OK, I got TNT installed and I managed to make it do a few simple things. The linear algebra package that comes with TNT is this thing called JAMA, which I am struggling to make work, with no success. The only kind of "documentation" I can find anywhere is the sort of gibberish (to me, anyway) to be found here:

http://math.nist.gov/tnt/jama_doxygen/class_JAMA__Eigenvalue.html

I have no idea what to do with that. I have little or no idea what a "class" even is, or what all those "::" are for. I wish the "documentation" would actually explain how to use the package. If I have a matrix, how can I get at the eigenvalues?

Can anybody more versed in C++ and all of this "class" and "::" business tell me what the correct syntax might be?

Thanks very much!
 
I think your problem is that you can't get there from here.

That is, these packages appear to assume you have a good knowledge of C++, and that doesn't come easily. First of all, you are going to have to get a good command of C++, then things will be much easier to understand.

The GNU C++ compiler is available for windows, and works fine, and is free. If these packages are written for Unix, then they will probably work with GNU C++ pretty naturally. Once again, a bit of a learning curve. You are going to have to get your hands dirty with things like make files, probably, as well.

I don't know if the free stuff here will do.http://www.vector-space.com/free.htm
 
a_unique_person said:
I think your problem is that you can't get there from here.

That is, these packages appear to assume you have a good knowledge of C++, and that doesn't come easily. First of all, you are going to have to get a good command of C++, then things will be much easier to understand.

The GNU C++ compiler is available for windows, and works fine, and is free. If these packages are written for Unix, then they will probably work with GNU C++ pretty naturally. Once again, a bit of a learning curve. You are going to have to get your hands dirty with things like make files, probably, as well.

I don't know if the free stuff here will do.http://www.vector-space.com/free.htm
As I mentioned in later posts, I did manage to find an implementation of TNT & JAMA that I can install on my windows system, so it's not a UNIX problem. It was just a matter of sticking all the .h files in the right directory. I even got some of the TNT stuff to work OK. My last remaining problem is that the syntax of the JAMA linear algebra functions is far from transparent, and I haven't been able to puzzle them out so far. I can't figure out what is an argument of what, and where all of the .'s and :'s and ()'s go.

Also, I may have been exaggerating a bit when I said that I am a rank beginner. I'm actually more in the middle. It's just that I've found through bitter experience over the years that when asking questions of computer gurus, you have to pretend to be much more of a novice than you are, otherwise the answer will be far too technical. I've actually been writing Molecular Dynamics codes in C++ for a couple of years now.

My problem is just that the "documentation" in the link I provided above is pretty sub-par, and all of the online "code samples" I've been able to find are contradictory and don't work when I try them out.
 
a_unique_person said:
Aha, you were obfuscating. I shall report you to the combat wombat immediately.
My apologies.

But I think I found the problem. My C++ compiler does not allow multiple declaration of the same variable in the same function, i.e.

for(int i = 0;i<10;i++){
stuff
}

for(int i = 0;i<20;i++){
other stuff
}

is not allowed. So I had to go through my .h files and fix all that by hand.

Bad Microsoft! Bad! No soup for you!

Now I can compute eigenvalues, although the routine is stunted: the JAMA package only comes with a utility for calculating both the eigenvalues and eigenvectors at once. Since I only care about the eigenvalues, this is terribly inefficient. For a 400x400 matrix, this process takes about 30 seconds, but it goes up like N^3 from there. So I won't be able to handle my matrices with 1,500<N<12,000 very well at all.
 
IIRC, no one can make a C++ compiler that can meet all the C++ specifications.

I learnt C++ at Uni, but came to the realisation that it was a language that was out of control. For basic programming, it is fine, but once you try to use the full abstraction facilities, it all gets too crazy.
 
a_unique_person said:
IIRC, no one can make a C++ compiler that can meet all the C++ specifications.
You mean that the ANSI standards are inconsistent? Interesting...

I learnt C++ at Uni, but came to the realisation that it was a language that was out of control. For basic programming, it is fine, but once you try to use the full abstraction facilities, it all gets too crazy.
This does not surprise me. I've been getting by with simple add/subtract/multiply/divide, plus rudimentary file input/output for years in C/C++. Now I'm having to do more complicated things and my brain is liquifying. But it's the only language I know, and I have a September 20th dissertation deadline, so no time to learn another...
 
Vorticity said:
You mean that the ANSI standards are inconsistent? Interesting...

He's right.

Back in the really old days, languages were just thrown together. This caused a lot of problems. So, back in the old days, the syntax and semantics of languages were defined formally and related directly to models of parsing and computation. C++ is a bit of a throwback. I don't know that anyone has ever proven that it is impossible to make a complete and consistent implementation, but it's a fairly strong conjecture that it isn't.

However, Visual C++ is a far poorer implementation than it needs to be. It was designed to model the way people wrote programs for WIN32 in C.
 
Vorticity said:
I think I found the problem. My C++ compiler does not allow multiple declaration of the same variable in the same function, i.e.

for(int i = 0;i<10;i++){
stuff
}

for(int i = 0;i<20;i++){
other stuff
}

is not allowed.
Declaring 2 indentically named variables in the same scope is never allowed. However, the ANSI spec defines the scope of a variable declared in a "for" statement to be the scope of the loop only, so your code above should compile with a fully ANSI compliant compiler.

Unfortunately, early versions of the MS compiler define the scope of a variable defined in a "for" statement to be the scope of the code block in which the "for" statement appears. Microsoft have been loathe to change to ANSI compliance regarding this particular anomoly since doing so will break a hell of a lot of existing source code.

When Microsoft designed C#, they changed the behaviour of "for" statements to match the ANSI standard since they were starting with a clean slate.
 
Vorticity said:

But I think I found the problem. My C++ compiler does not allow multiple declaration of the same variable in the same function

There may be some option setting withing the compiler preferences for that. I haven't used a windows compiler for many years so I don't know for certain, but I'd look for something along the lines of "full ANSI compliance".
 

Back
Top Bottom