|
IFPACK Development
|
00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 /* shell sort adopted from Edmond Chow */ 00031 00032 #include "shellSort_dh.h" 00033 00034 #undef __FUNC__ 00035 #define __FUNC__ "shellSort_int" 00036 void 00037 shellSort_int (const int n, int *x) 00038 { 00039 START_FUNC_DH int m, max, j, k, itemp; 00040 00041 m = n / 2; 00042 while (m > 0) 00043 { 00044 max = n - m; 00045 for (j = 0; j < max; j++) 00046 { 00047 for (k = j; k >= 0; k -= m) 00048 { 00049 if (x[k + m] >= x[k]) 00050 break; 00051 itemp = x[k + m]; 00052 x[k + m] = x[k]; 00053 x[k] = itemp; 00054 } 00055 } 00056 m = m / 2; 00057 } 00058 END_FUNC_DH} 00059 00060 #undef __FUNC__ 00061 #define __FUNC__ "shellSort_float" 00062 void 00063 shellSort_float (const int n, double *x) 00064 { 00065 START_FUNC_DH int m, max, j, k; 00066 double itemp; 00067 00068 m = n / 2; 00069 while (m > 0) 00070 { 00071 max = n - m; 00072 for (j = 0; j < max; j++) 00073 { 00074 for (k = j; k >= 0; k -= m) 00075 { 00076 if (x[k + m] >= x[k]) 00077 break; 00078 itemp = x[k + m]; 00079 x[k + m] = x[k]; 00080 x[k] = itemp; 00081 } 00082 } 00083 m = m / 2; 00084 } 00085 END_FUNC_DH} 00086 00087 00088 #if 0 00089 #undef __FUNC__ 00090 #define __FUNC__ "shellSort_int_float" 00091 void 00092 shellSort_int_float (int n, int *x, VAL_DH * xVals) 00093 { 00094 START_FUNC_DH int m, max, j, k, itemp; 00095 VAL_DH atemp; 00096 00097 m = n / 2; 00098 while (m > 0) 00099 { 00100 max = n - m; 00101 for (j = 0; j < max; j++) 00102 { 00103 for (k = j; k >= 0; k -= m) 00104 { 00105 if (x[k + m] >= x[k]) 00106 break; 00107 itemp = x[k + m]; 00108 atemp = xVals[k + m]; 00109 x[k + m] = x[k]; 00110 /* xVals[k+m] = xVals[k]; */ 00111 x[k] = itemp; 00112 xVals[k] = atemp; 00113 } 00114 } 00115 m = m / 2; 00116 } 00117 END_FUNC_DH} 00118 #endif
1.7.4