00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2.1 of the GNU Lesser General Public License 00011 as published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this program; if not, write the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00027 USA. 00028 00029 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00030 Mountain View, CA 94043, or: 00031 00032 http://www.sgi.com 00033 00034 For further information regarding this notice, see: 00035 00036 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00037 00038 */ 00039 00040 00041 /* ==================================================================== 00042 * ==================================================================== 00043 * 00044 * Module: vsqrt.c 00045 * $Revision: 1.5 $ 00046 * $Date: 04/12/21 14:58:21-08:00 $ 00047 * $Author: bos@eng-25.internal.keyresearch.com $ 00048 * $Source: /home/bos/bk/kpro64-pending/libm/SCCS/s.vsqrt.c $ 00049 * 00050 * Revision history: 00051 * 10-Feb-95 - Original Version 00052 * 00053 * Description: source code for vector sqrt function 00054 * 00055 * ==================================================================== 00056 * ==================================================================== 00057 */ 00058 00059 static char *rcs_id = "$Source: /home/bos/bk/kpro64-pending/libm/SCCS/s.vsqrt.c $ $Revision: 1.5 $"; 00060 00061 #include "libm.h" 00062 00063 #if defined(mips) && !defined(__GNUC__) 00064 extern void vsqrt(double *, double *, long, long, long); 00065 00066 #pragma weak vsqrt = __vsqrt 00067 #endif 00068 00069 #if defined(BUILD_OS_DARWIN) /* Mach-O doesn't support aliases */ 00070 extern void __vsqrt( double *x, double *y, long count, long stridex, 00071 long stridey ); 00072 #pragma weak vsqrt 00073 void vsqrt( double *x, double *y, long count, long stridex, long stridey ) { 00074 __vsqrt(x, y, count, stridex, stridey); 00075 } 00076 #elif defined(__GNUC__) 00077 extern void __vsqrt(double *, double *, long, long, long); 00078 void vsqrt() __attribute__ ((weak, alias ("__vsqrt"))); 00079 #endif 00080 00081 static const du Inf = 00082 {D(0x7ff00000, 0x00000000)}; 00083 00084 00085 /* ==================================================================== 00086 * 00087 * FunctionName vsqrt 00088 * 00089 * Description computes vector sqrt of arg 00090 * 00091 * ==================================================================== 00092 */ 00093 00094 void 00095 __vsqrt( double *x, double *y, long count, long stridex, long stridey ) 00096 { 00097 long i; 00098 double u; 00099 double z; 00100 double result; 00101 00102 /* i = 0, 1, ..., count-1; y[i*stridey] = sqrt(x[i*stridex]) */ 00103 00104 00105 for ( i=0; i<count; i++ ) 00106 { 00107 #ifdef _PREFETCH 00108 #pragma prefetch_ref=*(x+8) 00109 #pragma prefetch_ref=*(y+8) 00110 #endif 00111 00112 u = z = *x; 00113 00114 #ifdef _USES_RECIP_SQRT 00115 00116 /* If _USES_RECIP_SQRT is defined, the compiler uses a reciprocal sqrt to 00117 * compute sqrt, so we have to special case zero and infinity. 00118 */ 00119 00120 if ( z == 0.0 ) 00121 u = 1.0; 00122 00123 if ( z == Inf.d ) 00124 u = 1.0; 00125 #endif 00126 result = sqrt(u); 00127 00128 #ifdef _USES_RECIP_SQRT 00129 00130 if ( z == 0.0 ) 00131 result = z; 00132 00133 if ( z == Inf.d ) 00134 result = z; 00135 #endif 00136 *y = result; 00137 00138 x += stridex; 00139 y += stridey; 00140 } 00141 } 00142
1.5.6