From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id D6BAE7EE35 for ; Sat, 23 Apr 2016 17:41:34 +0200 (CEST) IronPort-PHdr: 9a23:0/pKExD/oY/qsrF8w9myUyQJP3N1i/DPJgcQr6AfoPdwSP78rsbcNUDSrc9gkEXOFd2CrakU26yJ6euxACQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTnkb/osMyKKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46FppIZ8VvDVcr40BYdECzA+Nmkz4oW/tB/NSiOA62EQF34KlR5QBgHD6lf2U8GinDH9s79W2DObJtHxVbA5EQ6r4aliTBvpwHMsNyQ4633Qksx9yphSrhyooxh+65PSYZ/QL/NgeaLQO90AEzkSFv1NXjBMV9vvJ7AECPAMaL5V Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=Christophe.Raffalli@univ-savoie.fr; spf=SoftFail smtp.mailfrom=raffalli@univ-savoie.fr; spf=None smtp.helo=postmaster@raffalli.eu Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of Christophe.Raffalli@univ-savoie.fr) identity=pra; client-ip=192.162.68.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="Christophe.Raffalli@univ-savoie.fr"; x-conformance=sidf_compatible Received-SPF: SoftFail (mail2-smtp-roc.national.inria.fr: domain of raffalli@univ-savoie.fr is inclined to not designate 192.162.68.177 as permitted sender) identity=mailfrom; client-ip=192.162.68.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="raffalli@univ-savoie.fr"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@raffalli.eu) identity=helo; client-ip=192.162.68.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="postmaster@raffalli.eu"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CqBACwlhtX/7FEosBehAt9vBSHTBABAQEBAQEBAWQngi2CFAEBAQMBIwQsAiQFCwsOCgkhAgIPBUkTCYgZCAQKrjGQdwELFgiGIYRLhz8rgisFh3SQG44KCoFmjSqGI4kMNyuCBByBTWoBiHoBAQE X-IPAS-Result: A0CqBACwlhtX/7FEosBehAt9vBSHTBABAQEBAQEBAWQngi2CFAEBAQMBIwQsAiQFCwsOCgkhAgIPBUkTCYgZCAQKrjGQdwELFgiGIYRLhz8rgisFh3SQG44KCoFmjSqGI4kMNyuCBByBTWoBiHoBAQE X-IronPort-AV: E=Sophos;i="5.24,523,1454972400"; d="asc'?scan'208";a="215542792" Received: from vps29067.lws-hosting.com (HELO raffalli.eu) ([192.162.68.177]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 23 Apr 2016 17:41:34 +0200 Received: from localhost (bin73-1-78-240-16-62.fbx.proxad.net [78.240.16.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by raffalli.eu (Postfix) with ESMTPSA id 646723520548; Sat, 23 Apr 2016 17:41:33 +0200 (CEST) Date: Sat, 23 Apr 2016 17:41:32 +0200 From: Christophe Raffalli To: Gerd Stolpmann Cc: caml-list@inria.fr Message-ID: <20160423154132.GB1455@delli7.univ-savoie.fr> References: <20160423091630.GA25686@delli7.univ-savoie.fr> <1461410500.26469.167.camel@e130.lan.sumadev.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline In-Reply-To: <1461410500.26469.167.camel@e130.lan.sumadev.de> User-Agent: Mutt/1.5.24 (2015-08-30) X-Validation-by: christophe.raffalli@univ-savoie.fr Subject: Re: [Caml-list] ocaml defaut hash ? --+g7M9IMkV8truYOl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 16-04-23 13:21:40, Gerd Stolpmann wrote: > Am Samstag, den 23.04.2016, 11:16 +0200 schrieb Christophe Raffalli: > > By the way what I really need is a hash function for arrays that I can > > update when I update one entry in the array. Does anyone known of > > such a hash function ? > > It would have to be commutative then (you need to remove the old version > and add the new one, for any element for the array). You could use XOR > or + of the hashes of the individual elements. Hello, xor or + was not enough and it does not have to be commutative. I tried let hash_array a =3D let r =3D ref 0 in Array.iteri (fun i x -> r :=3D !r lxor Hashtbl.hash (i,x)) a; !r Which works not to bad ... but some small hash value (below 10, after moduli) seems to come too often ... > If this doesn't work good enough, I'd try to define larger hash blocks. > E.g. consider 4 consecutive elements as a block, and compute the hash of > the block, and take the XOR of all blocks you have. This is already done. My array is in fact a packed array of values that can be represented on few bits, implemented cleanly via a functor. The property I would like if you think that the array is a 2 dimensional bi= tmaps are - the hash changes when any bit changes - the hash changes for all (most) translation at angle multiple of pi/4 with z=C3=A9ro padding (making xor no sufficient) - covering all range of caml integer as usual > Quality depends a > little bit on what is in the elements. > > Gerd > -- > ------------------------------------------------------------ > Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de > My OCaml site: http://www.camlcity.org > Contact details: http://www.camlcity.org/contact.html > Company homepage: http://www.gerd-stolpmann.de > ------------------------------------------------------------ > --+g7M9IMkV8truYOl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlcbl6wACgkQi9jr/RgYAS7eeACgvSGGQwJjM3zklz0Dl1XC1uwE r9QAn0hdi/bd5qR179PckFYFmL442E/P =ipqy -----END PGP SIGNATURE----- --+g7M9IMkV8truYOl--