Beispiel #1
0
/*
 *             Automatically Tuned Linear Algebra Software v3.10.2
 *                    (C) Copyright 1999 R. Clint Whaley
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions, and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *   3. The name of the ATLAS group or the names of its contributers may
 *      not be used to endorse or promote products derived from this
 *      software without specific written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
#ifdef TCPLX
static int ATL_potrf2(const int N, TYPE *A, const int lda)
{
   int j, k;
   static const TYPE one[2] = {ATL_rone, ATL_rzero};
   static const TYPE none[2] = {ATL_rnone, ATL_rzero};
   const size_t lda2 = lda+lda;
   TYPE Ajj, *Ac=A, *An=A+lda2;

   for (k=j=0; j != N; j++, k += 2)
   {
      Ajj = Ac[k] - llt_dot(k, Ac, 1, Ac, 1);
      Ac[k+1] = ATL_rzero;
      if (Ajj > ATL_rzero)
      {
         Ac[k] = Ajj = sqrt(Ajj);
         if (j != N-1)
         {
            llt_scal(j, ATL_rnone, Ac+1, 2);
            cblas_gemv(CblasColMajor, CblasTrans, j, N-j-1, none,
                       An, lda, Ac, 1, one, An+k, lda);
            llt_scal(j, ATL_rnone, Ac+1, 2);
            llt_rscal(N-j-1, ATL_rone/Ajj, An+k, lda);
            Ac = An;
            An += lda2;
         }
      }
      else
      {
         Ac[k] = Ajj;
         return(j+1);
      }
   }
   return(0);
}
#else  /* real version */
static int ATL_potrf2(const int N, TYPE *A, const int lda)
{
   int j;
   TYPE Ajj, *Ac=A, *An=A+lda;

   for (j=0; j != N; j++)
   {
      Ajj = Ac[j] - cblas_dot(j, Ac, 1, Ac, 1);
      if (Ajj > ATL_rzero)
      {
         Ac[j] = Ajj = sqrt(Ajj);
         if (j != N-1)
         {
            cblas_gemv(CblasColMajor, CblasTrans, j, N-j-1, ATL_rnone,
                       An, lda, Ac, 1, ATL_rone, An+j, lda);
            cblas_scal(N-j-1, ATL_rone/Ajj, An+j, lda);
            Ac = An;
            An += lda;
         }
      }
      else
      {
         Ac[j] = Ajj;
         return(j+1);
      }
   }
   return(0);
}
Beispiel #2
0
static int ATL_potrf2(const int N, TYPE *A, const int lda)
{
   int j, k;
   static const TYPE one[2] = {ATL_rone, ATL_rzero};
   static const TYPE none[2] = {ATL_rnone, ATL_rzero};
   const size_t lda2 = lda+lda;
   TYPE Ajj, *Ac=A, *An=A+lda2;

   for (k=j=0; j != N; j++, k += 2)
   {
      Ajj = Ac[k] - llt_dot(k, Ac, 1, Ac, 1);
      Ac[k+1] = ATL_rzero;
      if (Ajj > ATL_rzero)
      {
         Ac[k] = Ajj = sqrt(Ajj);
         if (j != N-1)
         {
            llt_scal(j, ATL_rnone, Ac+1, 2);
            cblas_gemv(CblasColMajor, CblasTrans, j, N-j-1, none,
                       An, lda, Ac, 1, one, An+k, lda);
            llt_scal(j, ATL_rnone, Ac+1, 2);
            llt_rscal(N-j-1, ATL_rone/Ajj, An+k, lda);
            Ac = An;
            An += lda2;
         }
      }
      else
      {
         Ac[k] = Ajj;
         return(j+1);
      }
   }
   return(0);
}
Beispiel #3
0
static int L2LU(const int M, const int N, TYPE *A, const int lda, int *ipiv)
/*
 * Complex Level 2 based left-looking LU
 */
{
   TYPE *Ac=A;
   TYPE t0, tmp[2];
   const TYPE one[2] = {ATL_rone, ATL_rzero}, none[2] = {ATL_rnone, ATL_rzero};
   const int MN=Mmin(M,N), MN_1=MN-1, lda2=lda+lda;
   int ip, ip2, j, j2, jn, jn2, iret=0;

   for (j=0, j2=0, jn=1, jn2=2; j != MN; j=jn++, j2 += 2, jn2 += 2)
   {
      ipiv[j] = ip = j + cblas_iamax(M-j, Ac+j2, 1);
      ip2 = ip + ip;
      if (Ac[ip2] != ATL_rzero || Ac[ip2+1] != ATL_rzero)
      {
         Mjoin(PATL,cplxinvert)(1, Ac+ip2, 1, tmp, 1);
         cblas_swap(N, A+j2, lda, A+ip2, lda);
         cblas_scal(M-jn, tmp, Ac+jn2, 1);
         if (j != MN_1)
         {
            Ac += lda2;
            cblas_trsv(CblasColMajor, CblasLower, CblasNoTrans, CblasUnit, jn,
                       A, lda, Ac, 1);
            cblas_gemv(CblasColMajor, CblasNoTrans, M-jn, jn, none,
                       A+jn2, lda, Ac, 1, one, Ac+jn2, 1);
         }
      }
      else if (!iret) iret = jn;
   }
   return(iret);
}
Beispiel #4
0
static int L2LU(const int M, const int N, TYPE *A, const int lda, int *ipiv)
/*
 * Level 2 based left-looking LU
 */
{
   TYPE *Ac=A;
   TYPE t0;
   const int MN=Mmin(M,N), MN_1=MN-1;
   int ip, j, jn, iret=0;

   if (N == 2) return(LU2(M, A, lda, ipiv));
   for (j=0, jn=1; j != MN; j=jn++)
   {
      ipiv[j] = ip = j + cblas_iamax(M-j, Ac+j, 1);
      t0 = Ac[ip];
      if (t0 != ATL_rzero)
      {
         MySwap(N, A+j, lda, ip-j);
         cblas_scal(M-jn, ATL_rone/t0, Ac+jn, 1);
         if (j != MN_1)
         {
            Ac += lda;
            cblas_trsv(CblasColMajor, CblasLower, CblasNoTrans, CblasUnit, jn,
                       A, lda, Ac, 1);
            cblas_gemv(CblasColMajor, CblasNoTrans, M-jn, jn, ATL_rnone,
                       A+jn, lda, Ac, 1, ATL_rone, Ac+jn, 1);
         }
      }
      else if (!iret) iret = jn;
   }
   return(iret);
}
Beispiel #5
0
/*
 *             Automatically Tuned Linear Algebra Software v3.11.28
 *                    (C) Copyright 1999 R. Clint Whaley
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions, and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *   3. The name of the ATLAS group or the names of its contributers may
 *      not be used to endorse or promote products derived from this
 *      software without specific written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
static int ATL_potrf2(const int N, TYPE *A, const int lda)
{
#ifdef TREAL
    TYPE Ajj, *Ac=A;
    const int N_1 = N-1;
    int j;

    for (j=0; j != N_1; j++, Ac += lda)
    {
       Ajj = Ac[j] - cblas_dot(j, A+j, lda, A+j, lda);

       if (Ajj > ATL_rzero)
       {
          Ac[j] = Ajj = sqrt(Ajj);
          cblas_gemv(CblasColMajor, CblasNoTrans, N-j-1, j, ATL_rnone,
                     A+j+1, lda, A+j, lda, ATL_rone, Ac+j+1, 1);
          cblas_scal(N-j-1, ATL_rone/Ajj, Ac+j+1, 1);
       }
       else
       {
          Ac[j] = Ajj;
          return(j+1);
       }
    }
    Ajj = Ac[j] - cblas_dot(j, A+j, lda, A+j, lda);
    if (Ajj > ATL_rzero) Ac[j] = Ajj = sqrt(Ajj);
    else
    {
       Ac[j] = Ajj;
       return(N);
    }
#else
    TYPE Ajj, *Ac=A;
    TYPE one[2] = {ATL_rone, ATL_rzero};
    TYPE none[2] = {ATL_rnone, ATL_rzero};
    const int N_1 = N-1, lda2 = lda<<1;
    int j, j2;

    for (j2=j=0; j != N_1; j++, j2 += 2, Ac += lda2)
    {
       Ajj = Ac[j2];
       cblas_dotc_sub(j, A+j2, lda, A+j2, lda, Ac+j2);
       Ajj -= Ac[j2];

       if (Ajj > ATL_rzero)
       {
          Ac[j2] = Ajj = sqrt(Ajj);
          llt_scal(j, ATL_rnone, A+j2+1, lda2);
          cblas_gemv(CblasColMajor, CblasNoTrans, N-j-1, j, none,
                     A+j2+2, lda, A+j2, lda, one, Ac+j2+2, 1);
          llt_scal(j, ATL_rnone, A+j2+1, lda2);
          llt_scal((N-j-1)<<1, ATL_rone/Ajj, Ac+j2+2, 1);
       }
       else
       {
          Ac[j2] = Ajj;
          return(j+1);
       }
    }
    Ajj = Ac[j2];
    cblas_dotc_sub(j, A+j2, lda, A+j2, lda, Ac+j2);
    Ajj -= Ac[j2];
    if (Ajj > ATL_rzero) Ac[j2] = sqrt(Ajj);
    else
    {
       Ac[j2] = Ajj;
       return(N);
    }
#endif
   return(0);
}