* [gentoo-science] [sci-mathemetics/freemat] freemat-3.2 ebuild
@ 2007-04-20 23:14 Carmelo Piccione
2007-04-21 0:11 ` Andrey G. Grozin
0 siblings, 1 reply; 2+ messages in thread
From: Carmelo Piccione @ 2007-04-20 23:14 UTC (permalink / raw
To: gentoo-science
[-- Attachment #1: Type: text/plain, Size: 143 bytes --]
Hey guys,
I made a freemat 3.2 ebuild. It works fine on my amd64 system using
same Math.* patches as the freemat 3.0 ebuild.
Thanks,
Carmelo
[-- Attachment #2: freemat-3.2.ebuild --]
[-- Type: text/plain, Size: 1035 bytes --]
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils autotools
DESCRIPTION="Freemat is a free environment for rapid engineering and scientific prototyping and data processing"
HOMEPAGE="http://freemat.sourceforge.net/"
MY_PN=FreeMat
MY_P="${MY_PN}-${PV}"
#### delete the next line when moving this ebuild to the main tree!
RESTRICT="nomirror"
SRC_URI="mirror://sourceforge/freemat/${MY_P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
DEPEND=">=sys-libs/ncurses-5.4-r5 virtual/blas virtual/lapack dev-libs/ffcall\
sci-libs/umfpack sci-libs/arpack >=x11-libs/qt-4.2"
S=${WORKDIR}/${MY_P}
src_unpack() {
unpack ${A}
cd ${S}
# epatch "${FILESDIR}/${PN}-${PV}.patch"
epatch "${FILESDIR}/Math.cpp.patch"
epatch "${FILESDIR}/Math.hpp.patch"
}
src_compile() {
eautoconf
econf || die "econf failed"
emake || die "emake failed"
}
src_install() {
make DESTDIR="${D}" install || die "install failed"
dodoc README AUTHORS ChangeLog
}
[-- Attachment #3: Math.cpp.patch --]
[-- Type: text/x-diff, Size: 6955 bytes --]
*** libs/libFreeMat/Math.cpp.orig Mon Apr 9 15:52:18 2007
--- libs/libFreeMat/Math.cpp Mon Apr 9 15:52:32 2007
***************
*** 78,373 ****
}
}
- template <class T>
- void addfullcomplex(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[2*i] = A[2*m] + B[2*p];
- C[2*i+1] = A[2*m+1] + B[2*p+1];
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void subtractfullreal(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = A[m] - B[p];
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void subtractfullcomplex(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[2*i] = A[2*m] - B[2*p];
- C[2*i+1] = A[2*m+1] - B[2*p+1];
- m += stride1;
- p += stride2;
- }
- }
-
-
- template <class T>
- void multiplyfullreal(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = A[m] * B[p];
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void multiplyfullcomplex(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[2*i] = A[2*m] * B[2*p] - A[2*m+1] * B[2*p+1];
- C[2*i+1] = A[2*m] * B[2*p+1] + A[2*m+1] * B[2*p];
- m += stride1;
- p += stride2;
- }
- }
-
-
- template <class T>
- void dividefullreal(int N, T*C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = A[m] / B[p];
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void complex_divide(T* c, const T* a, const T* b) {
- double ratio, den;
- double abr, abi, cr;
-
- if( (abr = b[0]) < 0.)
- abr = - abr;
- if( (abi = b[1]) < 0.)
- abi = - abi;
- if( abr <= abi )
- {
- if(abi == 0) {
- if (a[1] != 0 || a[0] != 0)
- abi = 1.;
- c[1] = c[0] = abi / abr;
- return;
- }
- ratio = b[0] / b[1] ;
- den = b[1] * (1 + ratio*ratio);
- cr = (a[0]*ratio + a[1]) / den;
- c[1] = (a[1]*ratio - a[0]) / den;
- }
- else
- {
- ratio = b[1] / b[0] ;
- den = b[0] * (1 + ratio*ratio);
- cr = (a[0] + a[1]*ratio) / den;
- c[1] = (a[1] - a[0]*ratio) / den;
- }
- c[0] = cr;
- }
-
- template <class T>
- void dividefullcomplex(int N, T*C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- complex_divide<T>(C+2*i,A+2*m,B+2*p);
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void lessthanfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] < B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- T complex_abs(T real, T imag) {
- double temp;
- if(real < 0)
- real = -real;
- if(imag < 0)
- imag = -imag;
- if(imag > real){
- temp = real;
- real = imag;
- imag = temp;
- }
- if((real+imag) == real)
- return(real);
- temp = imag/real;
- temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
- return(temp);
- }
-
-
- template <class T>
- void lessthanfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) <
- complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void lessequalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] <= B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void lessequalsfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) <=
- complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void equalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] == B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void equalsfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = ((A[2*m] == B[2*p]) &&
- (A[2*m+1] == B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void notequalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] != B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void notequalsfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = ((A[2*m] != B[2*p]) ||
- (A[2*m+1] != B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void greaterthanfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
- int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] > B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void greaterthanfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) >
- complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void greaterequalsfuncreal(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (A[m] >= B[p]) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
-
- template <class T>
- void greaterequalsfunccomplex(int N, logical* C, const T*A, int stride1,
- const T*B, int stride2) {
- int m, p;
- m = 0; p = 0;
- for (int i=0;i<N;i++) {
- C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) >=
- complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
- m += stride1;
- p += stride2;
- }
- }
/**
* These are the power functions...
--- 78,83 ----
[-- Attachment #4: Math.hpp.patch --]
[-- Type: text/x-diff, Size: 7325 bytes --]
*** libs/libFreeMat/Math.hpp.orig Mon Apr 9 15:52:21 2007
--- libs/libFreeMat/Math.hpp Mon Apr 9 15:52:27 2007
***************
*** 21,27 ****
#define __Math_hpp_
#include "Array.hpp"
!
/**
* Add the two argument arrays together: $$C_n = A_n + B_n$$.
*/
--- 21,27 ----
#define __Math_hpp_
#include "Array.hpp"
! #include <cmath>
/**
* Add the two argument arrays together: $$C_n = A_n + B_n$$.
*/
***************
*** 175,178 ****
--- 175,471 ----
double power_dd(double a, double b);
template <class T>
T complex_abs(T real, T imag);
+
+
+
+ template <class T>
+ void addfullcomplex(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[2*i] = A[2*m] + B[2*p];
+ C[2*i+1] = A[2*m+1] + B[2*p+1];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void subtractfullreal(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = A[m] - B[p];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void subtractfullcomplex(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[2*i] = A[2*m] - B[2*p];
+ C[2*i+1] = A[2*m+1] - B[2*p+1];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+
+ template <class T>
+ void multiplyfullreal(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = A[m] * B[p];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void multiplyfullcomplex(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[2*i] = A[2*m] * B[2*p] - A[2*m+1] * B[2*p+1];
+ C[2*i+1] = A[2*m] * B[2*p+1] + A[2*m+1] * B[2*p];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+
+ template <class T>
+ void dividefullreal(int N, T*C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = A[m] / B[p];
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void complex_divide(T* c, const T* a, const T* b) {
+ double ratio, den;
+ double abr, abi, cr;
+
+ if( (abr = b[0]) < 0.)
+ abr = - abr;
+ if( (abi = b[1]) < 0.)
+ abi = - abi;
+ if( abr <= abi )
+ {
+ if(abi == 0) {
+ if (a[1] != 0 || a[0] != 0)
+ abi = 1.;
+ c[1] = c[0] = abi / abr;
+ return;
+ }
+ ratio = b[0] / b[1] ;
+ den = b[1] * (1 + ratio*ratio);
+ cr = (a[0]*ratio + a[1]) / den;
+ c[1] = (a[1]*ratio - a[0]) / den;
+ }
+ else
+ {
+ ratio = b[1] / b[0] ;
+ den = b[0] * (1 + ratio*ratio);
+ cr = (a[0] + a[1]*ratio) / den;
+ c[1] = (a[1] - a[0]*ratio) / den;
+ }
+ c[0] = cr;
+ }
+
+ template <class T>
+ void dividefullcomplex(int N, T*C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ complex_divide<T>(C+2*i,A+2*m,B+2*p);
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void lessthanfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] < B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ T complex_abs(T real, T imag) {
+ double temp;
+ if(real < 0)
+ real = -real;
+ if(imag < 0)
+ imag = -imag;
+ if(imag > real){
+ temp = real;
+ real = imag;
+ imag = temp;
+ }
+ if((real+imag) == real)
+ return(real);
+ temp = imag/real;
+ temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
+ return(temp);
+ }
+
+
+ template <class T>
+ void lessthanfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) <
+ complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void lessequalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] <= B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void lessequalsfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) <=
+ complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void equalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] == B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void equalsfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = ((A[2*m] == B[2*p]) &&
+ (A[2*m+1] == B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void notequalsfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] != B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void notequalsfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = ((A[2*m] != B[2*p]) ||
+ (A[2*m+1] != B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void greaterthanfuncreal(int N, logical* C, const T*A, int stride1, const T*B,
+ int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] > B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void greaterthanfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) >
+ complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void greaterequalsfuncreal(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (A[m] >= B[p]) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
+
+ template <class T>
+ void greaterequalsfunccomplex(int N, logical* C, const T*A, int stride1,
+ const T*B, int stride2) {
+ int m, p;
+ m = 0; p = 0;
+ for (int i=0;i<N;i++) {
+ C[i] = (complex_abs<T>(A[2*m],A[2*m+1]) >=
+ complex_abs<T>(B[2*p],B[2*p+1])) ? 1 : 0;
+ m += stride1;
+ p += stride2;
+ }
+ }
#endif
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [gentoo-science] [sci-mathemetics/freemat] freemat-3.2 ebuild
2007-04-20 23:14 [gentoo-science] [sci-mathemetics/freemat] freemat-3.2 ebuild Carmelo Piccione
@ 2007-04-21 0:11 ` Andrey G. Grozin
0 siblings, 0 replies; 2+ messages in thread
From: Andrey G. Grozin @ 2007-04-21 0:11 UTC (permalink / raw
To: Carmelo Piccione; +Cc: gentoo-science
On Fri, 20 Apr 2007, Carmelo Piccione wrote:
> I made a freemat 3.2 ebuild. It works fine on my amd64 system using
> same Math.* patches as the freemat 3.0 ebuild.
Interesting. There is a freemat-3.2 ebuild by S.Fabbro at gentooscience,
without any patches. It builds and works fine for me (x86, gcc-4.1.1). Are
these patches really necessary? If so, why building on x86 works?
Andrey
--
gentoo-science@gentoo.org mailing list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-21 0:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-20 23:14 [gentoo-science] [sci-mathemetics/freemat] freemat-3.2 ebuild Carmelo Piccione
2007-04-21 0:11 ` Andrey G. Grozin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox