File indexing completed on 2023-05-28 05:10:58 UTC
view on githubraw file Latest commit b4daa243 on 2023-05-28 03:53:22 UTC
b4daa24319 Shre*0001
0002
0003
0004
0005
0006
0007
0008 #include <stdio.h>
0009
0010 void allzero_(int *array) {
0011 int *inArray = array ;
0012 int i = 0 ;
0013 while (i<1000) {
0014 *inArray = 0 ;
0015 inArray++ ;
0016 i++ ;
0017 }
0018 }
0019
0020 void allones_(int *array) {
0021 int *inArray = array ;
0022 int i = 0 ;
0023 while (i<1000) {
0024 *inArray = ~0 ;
0025 inArray++ ;
0026 i++ ;
0027 }
0028 }
0029
0030 void all226s_(int *array) {
0031 int *inArray = array ;
0032 int i = 0 ;
0033 while (i<1000) {
0034 *inArray = 226 ;
0035 inArray++ ;
0036 i++ ;
0037 }
0038 }
0039
0040 void displaybits_(int *array, int *n) {
0041 int *inArray = array ;
0042 int i = 0 ;
0043 int mask, j, bitone ;
0044 printf("\n") ;
0045 while (i<*n) {
0046 mask = (int)1 ;
0047 j = 0 ;
0048 while (j<32) {
0049 if (!mask) printf("mask is zero !\n") ;
0050 bitone = *inArray & mask ;
0051 if (bitone)
0052 printf("1") ;
0053 else
0054 printf("0") ;
0055 mask = mask<<1 ;
0056 j++ ;
0057 }
0058 printf("\n") ;
0059 if (mask) printf("mask is not zero !\n") ;
0060 inArray++ ;
0061 i++ ;
0062 }
0063 }
0064
0065 int countsetbits_(int *array0, int *array1, int *repeat, int *n) {
0066 int nbBytes = -1;
0067 int *inArray0 = array0 ;
0068 int *inArray1 = array1 ;
0069 int i = 0 ;
0070 int mask, j, bitone0, bitone1 ;
0071 int count = 0 ;
0072 while (i<*n && nbBytes==-1) {
0073 mask = (int)1 ;
0074 j = 0 ;
0075 while (j<32 && nbBytes==-1) {
0076 bitone0 = *inArray0 & mask ;
0077 bitone1 = *inArray1 & mask ;
0078 if ((bitone0 && bitone1) || (!bitone0 && !bitone1)) {
0079 count++ ;
0080 } else {
0081
0082 nbBytes = (int)((float)count)/((float)(*repeat*8)) ;
0083 }
0084 mask = mask<<1 ;
0085 j++ ;
0086 }
0087 inArray0++ ;
0088 inArray1++ ;
0089 i++ ;
0090 }
0091 return nbBytes ;
0092 }