예제 #1
0
 /// <summary>
 /// Round mercantilistic
 /// </summary>
 /// <param name="input">float complex number</param>
 /// <returns>rounded number</returns>
 /// <remarks>real and imaginaty parts are rounded independently. </remarks>
 public static fcomplex Round (fcomplex input){
     return new fcomplex(
             (float)Math.Round(input.real),
             (float)Math.Round(input.imag)
     );
 }
예제 #2
0
 public void cgeevx(char balance, char jobvl, char jobvr, char sense, int n, fcomplex[] A, int lda, fcomplex[] w, fcomplex[] vl, int ldvl, fcomplex[] vr, int ldvr, ref int ilo, ref int ihi, float[] scale, ref float abnrm, float[] rconde, float[] rcondv, ref int info) {
     acml_cgeevx(balance,jobvl,jobvr,sense,n,A,lda,w,vl,ldvl,vr,ldvr,ref ilo,ref ihi,scale,ref abnrm,rconde,rcondv,ref info); 
 }
예제 #3
0
 public void chegv (int itype, char jobz, char uplo, int n, fcomplex[] A, int lda, fcomplex[] B, int ldb, float  [] w, ref int info) {
     acml_chegv (itype, jobz, uplo, n, A, lda, B, ldb, w, ref info); 
 }
예제 #4
0
 public void cgetrs(char trans, int N, int NRHS, fcomplex[] A, int LDA, int[] IPIV, fcomplex[] B, int LDB, ref int info) {
     acml_cgetrs(trans,N,NRHS,A,LDA,IPIV,B,LDB,ref info); 
 }
예제 #5
0
 public void cgelsd(int m, int n, int nrhs, fcomplex[] A, int lda, fcomplex[] B, int ldb, float[] S, float RCond, ref int rank, ref int info) {
     cgelsd (m, n, nrhs, A, lda, B, ldb, S, RCond, ref rank, ref info); 
 }
예제 #6
0
 public void cgetri(int N, fcomplex[] A, int LDA, int[] IPIV, ref int info) {
     acml_cgetri(N, A, LDA, IPIV, ref info);
 }
예제 #7
0
 public void cungqr(int M, int N, int K, fcomplex[] A, int lda, fcomplex[] tau, ref int info) {
     acml_cungqr(M,N,K,A,lda,tau,ref info); 
 }
예제 #8
0
 /// <summary>
 /// Sinus hyperbolicus
 /// </summary>
 /// <param name="input">input</param>
 /// <returns>Sinus hyperbolicus of input</returns>
 /// <remarks><para>The sinus hyperbolicus is computed by the trigonometric euler equation: </para>
 /// <para>(Exp(input) - Exp(-1.0 * input)) / 2.0</para></remarks>
 public static fcomplex Sinh(fcomplex input) {
     fcomplex ret = new fcomplex(0, 2);
     fcomplex i = new fcomplex(0, (float)1.0);
     fcomplex mi = new fcomplex(0, (float)-1.0);
     return (Exp(input) - Exp(-1.0 * input)) / 2.0;
 }
예제 #9
0
 /// <summary>
 /// power of fcomplex number, complex exponent
 /// </summary>
 /// <param name="exponent">exponent</param>
 /// <returns>new fcomplex number with result</returns>
 public fcomplex Pow(fcomplex exponent) {
     fcomplex ret = (Log() * exponent);
     return ret.Exp();
 }
예제 #10
0
 /// <summary>
 /// Cosinus hyperbolicus
 /// </summary>
 /// <param name="input">input</param>
 /// <returns>cosinus hyperbolicus of input</returns>
 /// <remarks><para>The cosinus is computed by the trigonometric euler equation: </para>
 /// <para>(Exp(input) + Exp(-1.0 * input)) / 2.0</para></remarks>
 public static fcomplex Cosh(fcomplex input) {
     return (Exp(input) + Exp(-1.0f * input)) / 2.0f;
 }
예제 #11
0
 /// <summary>
 /// Sinus
 /// </summary>
 /// <param name="input">input</param>
 /// <returns>Sinus of input</returns>
 /// <remarks><para>The sinus is computed by the trigonometric euler equation: </para>
 /// <para>(Exp(i * input) - Exp(-1.0 * i * input)) / (2.0 * i)</para></remarks>
 public static fcomplex Sin(fcomplex input) {
     fcomplex i = new fcomplex(0, (float)1.0);
     fcomplex mi = new fcomplex(0, (float)-1.0);
     return (Exp(i * input) - Exp(mi * input)) / (2.0 * i);
 }
예제 #12
0
 /// <summary>
 /// Cosinus
 /// </summary>
 /// <param name="input">input</param>
 /// <returns>cosinus of input</returns>
 /// <remarks><para>The cosinus is computed by the trigonometric euler equation: </para>
 /// <para>0.5 * [exp(i input) + exp(-i input)]</para></remarks>
 public static fcomplex Cos(fcomplex input) {
     fcomplex i = new fcomplex(0, 1.0f);
     fcomplex ni = new fcomplex(0, -1.0f);
     return (Exp(i * input) + Exp(ni * input)) / 2.0f;
 }
예제 #13
0
 /// <summary>
 /// truncate a floating point complex value
 /// </summary>
 /// <param name="input">input</param>
 /// <returns>integer part of input</returns>
 /// <remarks>Operates on real and imaginary parts seperately.</remarks>
 public static fcomplex Truncate (fcomplex input){
     return new fcomplex(
             (float)Math.Truncate(input.real),
             (float)Math.Truncate(input.imag)
     );
 }
예제 #14
0
 /// <summary>
 /// Signum function
 /// </summary>
 /// <param name="input">float complex input</param>
 /// <returns> Signum of input</returns>
 /// <remarks>
 /// For numbers a = 0.0 + 0.0i, sign(a)'s real and imag parts are 0.0. 
 /// For all other numbers sign(a) is the projection onto the unit circle.</remarks>
 public static fcomplex Sign(fcomplex input){
     if (input.real == 0.0 && input.imag == 0.0)
         return new fcomplex(); 
     else {
         float mag = (float)Math.Sqrt(input.real * input.real + input.imag * input.imag); 
         return new fcomplex(
             input.real / mag,
             input.imag / mag);
     }
 }
예제 #15
0
 public void cgesvd(char jobz, int m, int n, fcomplex[] a, int lda, float[] s, fcomplex[] u, int ldu, fcomplex[] vt, int ldvt, ref int info) {
     acml_cgesvd(jobz, jobz, m, n, a, lda, s, u, ldu, vt, ldvt, ref info);
 }
예제 #16
0
 /// <summary>
 /// square root of fcomplex number
 /// </summary>
 /// <returns>square root</returns>
 public fcomplex Sqrt() {
     // Reference : numerical recipes in C: Appendix C
     fcomplex ret = new fcomplex();
     double x, y, w, r;
     if ( real == 0.0 && imag == 0.0)
         return ret;
     else {
         x = (float)Math.Abs(real);
         y = (float)Math.Abs( imag);
         if (x >= y) {
             r = y / x;
             w = Math.Sqrt(x) * Math.Sqrt(0.5 * (1.0 + Math.Sqrt(1.0 + r * r)));
         } else {
             r = x / y;
             w = Math.Sqrt(y) * Math.Sqrt(0.5 * (r + Math.Sqrt(1.0 + r * r)));
         }
         if ( real >= 0.0) {
             ret.real = (float)w;
             ret.imag = (float)( imag / (2.0 * w));
         } else {
             ret.imag = (float)(( imag >= 0) ? w : -w);
             ret.real = (float)( imag / (2.0 * ret.imag));
         }
         return ret;
     }
 }
예제 #17
0
 public void cpotri(char uplo, int n, fcomplex[] A, int lda, ref int info) {
     acml_cpotri(uplo,n, A, lda, ref info);
 }
예제 #18
0
 /// <summary>
 /// logarithm of fcomplex number
 /// </summary>
 /// <returns>natural logarithm</returns>
 /// <remarks>The logarithm of a complex number A is defined as follows: <br />
 /// <list type="none"><item>real part: log(abs(A))</item>
 /// <item>imag part: Atan2(imag(A),real(A))</item></list>
 /// </remarks>
 public fcomplex Log() {
     fcomplex ret = new fcomplex();
     ret.real = (float)Math.Log(Math.Sqrt( real *  real +  imag *  imag));
     ret.imag = (float)Math.Atan2( imag,  real);
     return ret;
 }
예제 #19
0
 public void cgeqrf(int M, int N, fcomplex[] A, int lda, fcomplex [] tau, ref int info) {
     acml_cgeqrf(M, N, A, lda, tau, ref info);
 }
예제 #20
0
 /// <summary>
 /// test if any of real or imaginary parts are NAN's
 /// </summary>
 /// <param name="input">complex number to test</param>
 /// <returns>true if any of real or imag part is not a number</returns>
 public static bool IsNaN(fcomplex input) {
     if (Single.IsNaN(input.real) || Single.IsNaN(input.imag)) 
         return true; 
     else 
         return false; 
 }
예제 #21
0
 public void cgeqp3 ( int M,int N,fcomplex [] A,int LDA,int [] JPVT,fcomplex [] tau,ref int info ) {
     acml_cgeqp3(M,N,A,LDA,JPVT,tau,ref info);
 }
예제 #22
0
 /// <summary>
 /// test if any of real or imaginary parts are neg. infinite
 /// </summary>
 /// <param name="input">complex number to test</param>
 /// <returns>true if any of real or imag part is negative infinite</returns>
 public static bool IsNegativeInfinity(fcomplex input) {  
     if (Single.IsNegativeInfinity(input.real) || Single.IsNegativeInfinity(input.imag)) 
         return true; 
     else 
         return false; 
 }
예제 #23
0
 public void cpotrs(char uplo, int n, int nrhs, fcomplex[] A, int lda, fcomplex[] B, int ldb, ref int info) {
     acml_cpotrs(uplo,n,nrhs,A,lda,B,ldb,ref info); 
 }
예제 #24
0
 /// <summary>
 /// test if any of real or imaginary parts are finite
 /// </summary>
 /// <param name="input">complex number to test</param>
 /// <returns>true if any of real and imag part is finite</returns>
 public static bool IsFinite (fcomplex input) {
     if (ILMath.isfinite(input.real) && ILMath.isfinite(input.imag)) 
         return true; 
     else 
         return false; 
 }
예제 #25
0
 public void cgelsy(int m, int n, int nrhs, fcomplex[] A, int lda, fcomplex[] B, int ldb, int[] JPVT0, float RCond, ref int rank, ref int info) {
     acml_cgelsy(m,n,nrhs,A,lda,B,ldb,JPVT0,RCond,ref rank,ref info);
 }
예제 #26
0
 private void Test_det() {
     int errorCode = 0; 
     try {
         ILArray<double> A = ILMath.counter(1.0,1.0,4,4);
         A[1] = 0.0;  // makes A nonsingular ..
         A[14] = 0.0; // - '' - 
         if (!ILMath.det(A).Equals(-360.0))
             throw new Exception("invalid result"); 
         // float 
         errorCode = 2; 
         ILArray<float> Af = ILMath.tosingle(A); 
         if (!ILMath.det(Af).Equals(-360.0f)) 
             throw new Exception("invalid result: float"); 
         // complex 
         errorCode = 3; 
         ILArray<complex> Ac = ILMath.real2complex(A,A); 
         if (!ILMath.det(Ac).Equals(new complex(1440,0.0))) 
             throw new Exception("invalid result: complex"); 
         Ac.SetValue(new complex(3,-4.0),0);
         if (ILMath.det(Ac).GetValue(0) - new complex(7.2000e+002, -1.6800e+003) >= 10e-5) {
             throw new Exception("invalid result: complex (2)"); 
         }
         // fcomplex 
         errorCode = 5; 
         ILArray<fcomplex> Afc = ILMath.real2fcomplex(A,A); 
         if (!ILMath.det(Afc).Equals(new fcomplex(1440.0f,0.0f))) 
             throw new Exception("invalid result: fcomplex"); 
         // special shapes 
         errorCode = 6; 
         A = ILArray<double>.empty(); 
         try {
             ILMath.det(A); 
         } catch (ILArgumentException) {
             Info("det: empty matrix threw exception - ok"); 
         }
         A = -4.70;
         if (!ILMath.det(A).Equals(A)) {
             throw new Exception("det: scalar double: invalid result");
         }
         Af = -4.70f;
         if (!ILMath.det(Af).Equals(Af)) {
             throw new Exception("det: scalar float: invalid result");
         }
         Ac = new complex(-4.70,45.0);
         if (!ILMath.det(Ac).Equals(Ac)) {
             throw new Exception("det: scalar complex: invalid result");
         }
         Afc = new fcomplex(-4.70f,-234.0f); 
         if (!ILMath.det(Afc).Equals(Afc)) {
             throw new Exception("det: scalar fcomplex: invalid result");
         }
         Success();
     } catch(Exception e) {
         Error(errorCode,e.Message); 
     }
 }
예제 #27
0
 public void cheevr(char jobz, char range, char uplo, int n, fcomplex[] A, int lda, float vl, float vu, int il, int iu, float abstol, ref int m, float[] w, fcomplex[] z, int ldz, int[] isuppz, ref int info) {
     acml_cheevr(jobz,range,uplo,n,A,lda,vl,vu,il,iu,abstol,ref m,w,z,ldz,isuppz,ref info); 
 }
예제 #28
0
 public void cgemm(char TransA, char TransB, int M, int N, int K, fcomplex alpha, IntPtr A, int lda, IntPtr B, int ldb, fcomplex beta, fcomplex [] C, int ldc) {
     acml_cgemm(ref TransA, ref TransB, ref M, ref N, ref K, ref alpha, A, ref lda, B, ref ldb, ref beta, C, ref ldc);
 }
예제 #29
0
		private static extern void acml_cgemm(ref char TransA, ref char TransB, ref int M, ref int N, ref int K, ref fcomplex alpha, IntPtr A, ref int lda, IntPtr B, ref int ldb, ref fcomplex beta, [In, Out] fcomplex[] C, ref int ldc);
예제 #30
0
 /// <summary>
 /// Round towards next lower integer
 /// </summary>
 /// <param name="input">float complex input</param>
 /// <returns>rounded float complex number</returns>
 /// <remarks>real and imaginary parts are independently rounded 
 /// towards the next integer value towards negative infinity.</remarks>
 public static fcomplex Floor (fcomplex input){
     return new fcomplex(
             (float)Math.Floor(input.real),
             (float)Math.Floor(input.imag)
     );
 }