Octopus
checksum.c
Go to the documentation of this file.
1
/*
2
Copyright (C) 2010 X. Andrade
3
Copyright (C) 2021 S. Ohlmann
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2, or (at your option)
8
any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
02110-1301, USA.
19
20
*/
21
22
#include <
config.h
>
23
#include <
fortran_types.h
>
24
25
/* This function implements a very stupid checksum function. The only
26
important thing is that it produces different results for arrays
27
with the same numbers but in different orders. For more serious
28
applications a better function must be used. */
29
30
void
FC_FUNC_(checksum_calculate,
31
CHECKSUM_CALCULATE)(
const
fint
*algorithm,
const
fint8
*narray,
32
const
fint8
*array,
fint8
*sum) {
33
fint8
i
;
34
fint8
mult;
35
*sum = 0;
36
mult = 1;
37
for
(
i
= 0;
i
< *narray;
i
++) {
38
*sum += mult * array[
i
];
39
mult++;
40
}
41
}
config.h
fortran_types.h
fint8
long long int fint8
Definition:
fortran_types.h:16
fint
int fint
Definition:
fortran_types.h:14
i
ptrdiff_t i
Definition:
operate_inc.c:12
math
checksum.c
Generated on Fri Nov 22 2024 10:43:12 for Octopus by
1.9.4