Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Linear Algebra Object Types

Linear Algebra Object Types
Thread Tools
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 10, 2002, 05:11 PM
 
I'm looking for a way to use vectors and matrices as defined by linear algebra. I know it's possible to do this with AltiVec, but I'm also concerned about doing this on a G3 processor, not just a G4. I really don't want to have to start from scratch and define these myself.

I've just recently stumbled across the vecLib FrameWork in the System folder. I haven't seen any real documentation on it yet, but I'm reading the header files. Is this library AltiVec accelerated? If so, will it also work properly on non-G4's?


Thanks in advance for any information or advice.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 10, 2002, 05:45 PM
 
I found the answer to my own question (mostly).

/Developer/Documentation/CoreTechnologies/vDSP/vDSP_Library.pdf


From what I can tell, through skimming this pdf and skimming through the actual header files, it's up to the developer to determine whether or not the machine has AltiVec available. I wouldn't even know where to begin to look to find this. Also, some of the functions in the vecLib framework don't use altivec at all. So it seems it's entirely possible to do basic linear algebra subroutines (BLAS) without the G4... you just have to use different functions.


hmmm... no fun. I couldn't afford spending the extra $1000 for my laptop to match my desktop. oh well.


Any input is still appreciated.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Mar 10, 2002, 06:03 PM
 
There's some pretty good stuff for numerical computing on OS X at:
http://floyd.liunet.edu/~gkhanna/hpc.html

Enjoy,
iMac 17" G4 800MHZ & 768 SDRAM
     
Forum Regular
Join Date: Mar 2002
Location: Düsseldorf, Germany, Europe, Earth
Status: Offline
Reply With Quote
Mar 10, 2002, 07:55 PM
 
As far as I know, AltiVec would limit you to work in up to four dimensions anyway (unless you use 8bit integers, then you get 16).

If you happen to have big matrices and end up coding your own matrix multiplication (it's not implemented in vDSPlib) , you might want to check out Strassen's algorithm (see Introduction to Algorithms by Cormen, Leiserson, Rivest - or web search).
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Mar 11, 2002, 12:19 AM
 
Actually, a CS vector has nothing to do with a LinAlg vector. The Computer Science concept vector calculation is a row of numbers that you do the same thing to. For example take the vector 4 : 6 : 8 : 3, and do a vector add of 1 to them (implicitly 1 : 1 : 1 : 1) and you get 5 : 7 : 9 : 4. The Math/Geometric concept is very different.

If you were brute forcing the equations, or calculating end results, then AltiVec might come in handy to paralelize the operations, but teh AltiVec unit is not going to make symbolic math programming any easier.
     
Addicted to MacNN
Join Date: Dec 1999
Location: Tampa, Florida
Status: Offline
Reply With Quote
Mar 11, 2002, 01:59 AM
 
Shouldn't vector operations (mathematical or geometric) be hand-optimized in assembly to take advantage of Altivec? How does one know that code is being G4-optimized?
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 11, 2002, 09:54 AM
 
Originally posted by DaGuy:
<STRONG>There's some pretty good stuff for numerical computing on OS X at:
http://floyd.liunet.edu/~gkhanna/hpc.html

Enjoy,
</STRONG>

Actually, I've seen that site. It came in quite handy for my parallel programming class. However, I didn't find it entirely useful for this other project, as the vectorizing compilers aren't free (best I could tell), and they also won't work with Cocoa (Objective-C). I could, technically, do the work in C++, but then I would have to write an additional objective-c class to interact between the C++ class and the user interface. ...not much fun.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 11, 2002, 09:56 AM
 
Originally posted by The Godfather:
<STRONG>Shouldn't vector operations (mathematical or geometric) be hand-optimized in assembly to take advantage of Altivec? How does one know that code is being G4-optimized?</STRONG>
There are certain libraries offered by Apple that have already been written to take advantage of AltiVec and that have been hand optimized. If the developer uses those functions, the developer gets the benefits of AltiVec without writing assembly by hand.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Mar 11, 2002, 12:44 PM
 
You want MathArray

ftp://next-ftp.peak.org/pub/openstep/multi-platforms/sourcelibrary/classes/MathArray.0.60.s.tar.gz
ftp://ftp.informatik.uni-muenchen.de/pub/comp/platforms/next/Science/mathematics/MathArray.0.60.s.tar.gz

From the readme:

"MathArray is a general library of classes for performing mathematical operations on arrays (vectors, matrices, etc) of values. It can operate on any standard 'C' number type plus numbers of complex type."

-Peter
     
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
Mar 11, 2002, 02:41 PM
 
Originally posted by Detrius:
<STRONG>I'm looking for a way to use vectors and matrices as defined by linear algebra. I know it's possible to do this with AltiVec, but I'm also concerned about doing this on a G3 processor, not just a G4. I really don't want to have to start from scratch and define these myself.

I've just recently stumbled across the vecLib FrameWork in the System folder. I haven't seen any real documentation on it yet, but I'm reading the header files. Is this library AltiVec accelerated? If so, will it also work properly on non-G4's?


Thanks in advance for any information or advice.</STRONG>

Just some advice . . . be concerned about doing the linear algebra before you pay too much attention to performance optimization (G4 vs. G3 vs. whatever). "Linear Algebra" and "vectorization of code" are two completely different things. The G4 vectorizes it's object codeprocessing - that's not the same thing as a "vector and matrix" in linear algebra.

Writing some classes that represent the linear math concepts of a vector anda matrix and the mathmetical operations between them is a good excercise for any programmer (I did it myself years ago). Once you do that, then revist the code for performance optimization with G4 AltiVec vectorization. In the mean time, keep your terms straight.

Michael Kamprath
--
Michael F. Kamprath
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 12, 2002, 06:34 PM
 
Originally posted by kamprath:
<STRONG>


Just some advice . . . be concerned about doing the linear algebra before you pay too much attention to performance optimization (G4 vs. G3 vs. whatever). "Linear Algebra" and "vectorization of code" are two completely different things. The G4 vectorizes it's object codeprocessing - that's not the same thing as a "vector and matrix" in linear algebra.

Writing some classes that represent the linear math concepts of a vector anda matrix and the mathmetical operations between them is a good excercise for any programmer (I did it myself years ago). Once you do that, then revist the code for performance optimization with G4 AltiVec vectorization. In the mean time, keep your terms straight.

Michael Kamprath</STRONG>

I didn't ever get the terms mixed up. I've written code for linear algebra vectors and matrices before, but I just don't feel like porting them over to objective-c. I was hoping for pre-existing code that I could use instead of porting it.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
Mar 12, 2002, 08:42 PM
 
Originally posted by Detrius:
<STRONG>


I didn't ever get the terms mixed up. I've written code for linear algebra vectors and matrices before, but I just don't feel like porting them over to objective-c. I was hoping for pre-existing code that I could use instead of porting it.</STRONG>
You don't need to port them to objective-C, why would you think that? If they are in C++ (which I am assuming), and if you want to write a Cocoa-based front end, you can use Apple's Objective-C++ compiler that came with the Dev-Tools December CD. This compiler allows you to intermix objective-C and C++ code. So, if you want to write a Cocoa based front end, you can still use your suite of C/C++ code. Pretty cool.

If you wrote your stuff in Pascal, or some other language, just create a dynamically linked library and export a C-API to it's methods.

:rant on:
Why does everyone think Objective-C is the only thing you can work in on MacOS X? The only reason Objective-C exists is because C++ wasn't ready for the prime time when NextSTEP was originally invented . . .
What's it been since then . . 13 years? I didn't see Be using Objective-C in their system. Be used C++, and it was a dream to program for . . . too bad they tried to bluff Apple :-/
:rant off:

Michael
--
Michael F. Kamprath
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 12, 2002, 09:51 PM
 
Originally posted by kamprath:
<STRONG>

You don't need to port them to objective-C, why would you think that? If they are in C++ (which I am assuming), and if you want to write a Cocoa-based front end, you can use Apple's Objective-C++ compiler that came with the Dev-Tools December CD. This compiler allows you to intermix objective-C and C++ code. So, if you want to write a Cocoa based front end, you can still use your suite of C/C++ code. Pretty cool.

If you wrote your stuff in Pascal, or some other language, just create a dynamically linked library and export a C-API to it's methods.

:rant on:
Why does everyone think Objective-C is the only thing you can work in on MacOS X? The only reason Objective-C exists is because C++ wasn't ready for the prime time when NextSTEP was originally invented . . .
What's it been since then . . 13 years? I didn't see Be using Objective-C in their system. Be used C++, and it was a dream to program for . . . too bad they tried to bluff Apple :-/
:rant off:

Michael</STRONG>

Actually, I've always read that you could use Objective-C and C++ in the same program with the gcc compiler. I tried it, but couldn't get it to compile. I didn't try very hard, but nevertheless, it didn't work. The C++ header file spat out a really bizarre error: the word "class" was not recognized. Without this, of course, there could be no compiling of the C++ class. If you have any pointers for how to get it to compile, I'd be glad to use my own classes until I find better optimized ones.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Forum Regular
Join Date: Jul 2001
Location: Québec, Canada
Status: Offline
Reply With Quote
Mar 13, 2002, 07:09 AM
 
I think if you want a file to compile usign Objective-C++ you need to use the .mm extention.
     
Detrius  (op)
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 13, 2002, 09:08 AM
 
Originally posted by Michel Fortin:
<STRONG>I think if you want a file to compile usign Objective-C++ you need to use the .mm extention.</STRONG>
My first mental response to this was wondering what difference this would actually make, as this wouldn't have any effect on the header files. But then, I did a little bit of research on the web and found that this is indeed correct. This would be done for both C++ and Objective-C code--anything that will be using the two languages interchangeably.


Here's the reference document:
http://developer.apple.com/techpubs/...ctive-C++.html

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2