forum.alglib.net
http://forum.alglib.net/

ALGLIB with Texas Instruments Code Composer Studio
http://forum.alglib.net/viewtopic.php?f=2&t=84
Page 1 of 3

Author:  norrizuan [ Wed Oct 20, 2010 10:15 am ]
Post subject:  ALGLIB with Texas Instruments Code Composer Studio

Hi,
I just found out about ALGLIB. Just a quick question, can we use ALGLIB with TI Code Composer Studio ? Have anyone tried this yet?

Thanks in advance.

Regards,
Rizuan

Author:  Sergey.Bochkanov [ Wed Oct 20, 2010 12:41 pm ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Several questions:
* what ALGLIB functions you want to use?
* what CPU you want to use?

ALGLIB requires IEEE-compatible double precision floating point numbers (single precision support is not enough). So you may have problems when compiling for embedded systems. However, in some cases it is possible to modify ALGLIB so that functions you need will work. I can say more if you tell me more :)

Author:  norrizuan [ Thu Oct 21, 2010 10:10 am ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Hi Sergey,

Thanks for reply. I'm going to use OMAP-L137 Low Power Applications Processor with TMS320C6747 DSP and it support IEEE Double Precision/64-bit floating point. Currentlly, I'm thinking of using smatrixevd to calculate eigenvalue and eigenvector of my matrices. Do you think ALGLIB can be used with that DSP ?

I'm wondering if ALGLIB can perform covariance matrix calculation efficiently like in Matlab as well? Covariance matrix calculation is simple but it requires so many iteration. I'm using basic formula Cov(A,B) = mean(A.B) - mean(A).mean(B). In Visual C++, it took around 4-5 minutes just to calculate covariance matrix with dimension 224 x 224. In Matlab, we can get the result in a few seconds.

Sorry for double questions. But the main issue is can we use ALGLIB with the DSP that supports IEEE Double Precision floating point ?

Regards,
Rizuan

Author:  Sergey.Bochkanov [ Thu Oct 21, 2010 11:33 am ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Quote:
Sorry for double questions. But the main issue is can we use ALGLIB with the DSP that supports IEEE Double Precision floating point ?

Yes, it is the main issue, but there is one more thing to account for (see below). Your CPU should be either little or big endian, but not mixed endian. From http://focus.ti.com/lit/ds/symlink/omap-l137.pdf I can assume that ALGLIB will work for you.

Another issue possible - compiler being used. ALGLIB initialization code does tricky operations with pointers and double precision numbers to determine system properties at runtime. Although this autodetection code is 100% ANSI C conformant (and is full of optimization-preventing modifiers), some old and broken compilers can overoptimize these operations. MSVC, Sun Studio or modern GCC correctly handle it, but there was a thread recently about bug in the old GCC - viewtopic.php?f=2&t=69

I haven't tested ALGLIB with Texas Instruments C++ compiler, but you can easily do it:
* read http://www.alglib.net/translator/man/ma ... gs_testing
* download patch published at the top of viewtopic.php?f=2&t=69&start=11 and overwrite your copy of ALGLIB with these files (it was not included into 3.0, so you should do it manually). This patch improves situation with overoptimization of autodetection code.
* try to test without optimization, then with full optimization settings
* try both test_i.cpp and test_c.cpp (I recommend you to start from test_i.cpp).
* in any case - whether it fails or works - please, write here about results ;)

As for the covariance matrix, you can improve situation by using Cov(A,B) = mean { (A-mean(A))*(B-mean(B)) }:
* center your variables by subtracting their means
* make one big rectangular matrix from variables
* calculate product of centered vars as product of two matrices. use alglib::rmatrixgemm() to calculate it efficiently.
* then divide result by N - you have your covariance matrix.
Actually, I wanted to implement this code long ago... Maybe it will be done in 3.1 (will be released at the end of the month)

Author:  norrizuan [ Tue Oct 26, 2010 2:46 pm ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Hello Sergey and others who read this thread,

I'm happy to hear that about ALGLIB and Code Composer Studio. I'm not doing that right now, but surely I will let everyone know the results later through here.

And yeap, that is the formulae for covariance matrix I'm using. But I have 224 different vectors to calculate the covariance value. eg. cov(1st, 2nd), cov(1st, 3rd) ...... cov(1st, 224th), cov(2nd, 2nd), cov(2nd, 3rd) .... cov(2nd, 224th) and so on. This makes the process takes time to complete since there are multiplication in our formula between two variables. I'm going to try using alglib::rmatrixgemm() after this. Thanks for the suggestions. Will let you know later.

Regards,
Rizuan

Author:  Sergey.Bochkanov [ Wed Oct 27, 2010 12:43 pm ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

OK, waiting for your results. It is really interesting to hear about ALGLIB being used in embedded platforms.

Author:  norrizuan [ Tue Feb 08, 2011 10:03 am ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Hi Sergey,
I'm back on trying the ALGLIB in Code Composer Studio. I've got a lot of errors and warning. I just followed the similar steps when I want to try run the test_i.c and test_c.c in Visual C++ (Visual Studio 2010). I'm using your latest version, 3.2.0. Do you have any advice ? Code Composer Studio use C codes (I think so, because they use malloc for allocating dynamic array).

Really stuck right here.

Rizuan

Author:  Sergey.Bochkanov [ Tue Feb 08, 2011 10:23 am ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Can you post compiler log here? As attachment, if possible, because it can be too long.

If Code Composer Studio is just incompatible in some way with ANSI C++, we can try to find some workaround. But if it is in fact C compiler, then things are somewhat harder - it is possible to use plain C version of ALGLIB, but it is not user friendly and not intended to be used directly. But why do you think that it is C compiler, not C++ one? I've googled for a while, and it seems that Texas Instruments Code Composer Studio supports both C and C++.

Author:  norrizuan [ Thu Feb 10, 2011 11:50 am ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Hi Sergey,

Here is a good news (maybe). I can compile the test_i.cpp but with warnings (in Build Logs.txt). The output lsfit_d_spline is failed however (stdout.txt). Can you explain what is this about. There are also a few lines that is unreachable. All the other warnings are just for unused variables. However, most of the variables are used in the codes, but the compiler still give the warnings. Can you suggest any solutions?

Rizuan

Attachments:
File comment: Build logs with warnings
Build Logs.txt [9.96 KiB]
Downloaded 825 times
File comment: Output file from the code
Stdout.txt [86 Bytes]
Downloaded 831 times

Author:  norrizuan [ Thu Feb 10, 2011 1:17 pm ]
Post subject:  Re: ALGLIB with Texas Instruments Code Composer Studio

Hi Sergey,
I've tested the ALGLIB by using the test_c.cpp. The output is as attached.

Attachments:
File comment: Output when running test_c.cpp
Stdout test_c.txt [2.73 KiB]
Downloaded 848 times

Page 1 of 3 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/