“Fossies” – the Fresh Open Source Software Archive 
Member “gromacs-2021.3/src/external/tng_io/src/compression/dict.c” (18 Aug 2021, 972 Bytes) of package /linux/privat/gromacs-2021.3.tar.gz:
As a special service “Fossies” has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option.
Alternatively you can here view or download the uninterpreted source code file.
For more information about “dict.c” see the Fossies “Dox” file reference documentation.
Alternatively you can here view or download the uninterpreted source code file.
For more information about “dict.c” see the Fossies “Dox” file reference documentation.
1 /* This code is part of the tng compression routines. 2 * 3 * Written by Daniel Spangberg and Magnus Lundborg 4 * Copyright (c) 2010, 2013-2014 The GROMACS development team. 5 * 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the Revised BSD License. 9 */ 10 11 12 #include <string.h> 13 #include "../../include/compression/dict.h" 14 15 void Ptngc_comp_canonical_dict(unsigned int *dict, int *ndict) 16 { 17 int i; 18 for (i=0; i<0x20004; i++) 19 dict[i]=i; 20 21 *ndict=0x20004; 22 } 23 24 void Ptngc_comp_make_dict_hist(unsigned int *vals, const int nvals, 25 unsigned int *dict, int *ndict, 26 unsigned int *hist) 27 { 28 int i; 29 int j=0; 30 31 memset(hist, 0, sizeof(unsigned int)*0x20004); 32 33 for (i=0; i<nvals; i++) 34 hist[vals[i]]++; 35 for (i=0; i<0x20004; i++) 36 if (hist[i]!=0) 37 { 38 hist[j]=hist[i]; 39 dict[j]=i; 40 j++; 41 if(j==nvals) 42 break; 43 } 44 *ndict=j; 45 }
Read more here: Source link