Binary files /tmp/tmpBvefoj/7PSAON5gWK/r-cran-bit64-0.9-7.1/data/benchmark64.data.rda and /tmp/tmpBvefoj/BKupuqWLH8/r-cran-bit64-4.0.5/data/benchmark64.data.rda differ Binary files /tmp/tmpBvefoj/7PSAON5gWK/r-cran-bit64-0.9-7.1/data/optimizer64.data.rda and /tmp/tmpBvefoj/BKupuqWLH8/r-cran-bit64-4.0.5/data/optimizer64.data.rda differ diff -Nru r-cran-bit64-0.9-7.1/debian/changelog r-cran-bit64-4.0.5/debian/changelog --- r-cran-bit64-0.9-7.1/debian/changelog 2020-07-29 20:02:31.000000000 +0000 +++ r-cran-bit64-4.0.5/debian/changelog 2020-09-01 14:57:35.000000000 +0000 @@ -1,3 +1,9 @@ +r-cran-bit64 (4.0.5-1) unstable; urgency=medium + + * New upstream version + + -- Andreas Tille Tue, 01 Sep 2020 16:57:35 +0200 + r-cran-bit64 (0.9-7.1-1) unstable; urgency=medium * Team upload. diff -Nru r-cran-bit64-0.9-7.1/debian/control r-cran-bit64-4.0.5/debian/control --- r-cran-bit64-0.9-7.1/debian/control 2020-07-29 20:02:31.000000000 +0000 +++ r-cran-bit64-4.0.5/debian/control 2020-09-01 14:57:35.000000000 +0000 @@ -7,7 +7,7 @@ Build-Depends: debhelper-compat (= 13), dh-r, r-base-dev, - r-cran-bit + r-cran-bit (>= 4.0.0) Standards-Version: 4.5.0 Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-bit64 Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-bit64.git diff -Nru r-cran-bit64-0.9-7.1/DESCRIPTION r-cran-bit64-4.0.5/DESCRIPTION --- r-cran-bit64-0.9-7.1/DESCRIPTION 2020-07-15 04:56:13.000000000 +0000 +++ r-cran-bit64-4.0.5/DESCRIPTION 2020-08-30 07:20:02.000000000 +0000 @@ -1,11 +1,11 @@ Package: bit64 Type: Package Title: A S3 Class for Vectors of 64bit Integers -Version: 0.9-7.1 -Date: 2017-05-07 -Author: Jens Oehlschlägel +Version: 4.0.5 +Date: 2020-08-29 +Author: Jens Oehlschlägel [aut, cre], Leonardo Silvestri [ctb] Maintainer: Jens Oehlschlägel -Depends: R (>= 3.0.1), bit (>= 1.1-12), utils, methods, stats +Depends: R (>= 3.0.1), bit (>= 4.0.0), utils, methods, stats Description: Package 'bit64' provides serializable S3 atomic 64bit (signed) integers. These are useful for handling database keys and exact counting in +-2^63. @@ -17,12 +17,15 @@ characters and factors as well as many elementwise and summary functions. Many fast algorithmic operations such as 'match' and 'order' support inter- active data exploration and manipulation and optionally leverage caching. -License: GPL-2 +License: GPL-2 | GPL-3 LazyLoad: yes ByteCompile: yes -URL: http://ff.r-forge.r-project.org/ +URL: https://github.com/truecluster/bit64 Encoding: UTF-8 -NeedsCompilation: yes -Packaged: 2020-07-14 17:48:42 UTC; ripley Repository: CRAN -Date/Publication: 2020-07-15 04:56:13 UTC +Repository/R-Forge/Project: ff +Repository/R-Forge/Revision: 177 +Repository/R-Forge/DateTimeStamp: 2018-08-17 17:45:18 +Date/Publication: 2020-08-30 07:20:02 UTC +NeedsCompilation: yes +Packaged: 2020-08-29 10:56:45 UTC; jo diff -Nru r-cran-bit64-0.9-7.1/exec/prebuild.sh r-cran-bit64-4.0.5/exec/prebuild.sh --- r-cran-bit64-0.9-7.1/exec/prebuild.sh 2017-04-08 15:25:51.000000000 +0000 +++ r-cran-bit64-4.0.5/exec/prebuild.sh 2020-06-14 15:15:59.000000000 +0000 @@ -1,17 +1,17 @@ -#!/bin/sh - -# Produce the Rd-files for the documentation from the R source files -# -# Prerequisites: -# - Perl -# - R_HOME must be set to the directory where R is installed - -echo "#### starting prebuild.sh" - -cd .. -mkdir -p man -cd man -find ../R -name '*.[rR]' -exec cat \{\} \; | perl ../exec/make_rd.pl -cd ../exec - -echo "#### prebuild.sh completed!" +#!/bin/sh + +# Produce the Rd-files for the documentation from the R source files +# +# Prerequisites: +# - Perl +# - R_HOME must be set to the directory where R is installed + +echo "#### starting prebuild.sh" + +cd .. +mkdir -p man +cd man +find ../R -name '*.[rR]' -exec cat \{\} \; | perl ../exec/make_rd.pl +cd ../exec + +echo "#### prebuild.sh completed!" diff -Nru r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.8.txt r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.8.txt --- r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.8.txt 2017-04-14 11:44:25.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.8.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Dear R-Core team, -Dear Rcpp team and other package teams, -Dear R users, - -The new package 'bit64' is available on CRAN for beta-testing and code-reviewing. - -Package 'bit64' provides fast serializable S3 atomic 64bit (signed) integers that can be used in vectors, matrices, arrays and data.frames. Methods are available for coercion from and to logicals, integers, doubles, characters as well as many elementwise and summary functions. - -Package 'bit64' has the following advantages over package 'int64' (which was sponsored by Google): -- true atomic vectors usable with length, dim, names etc. -- only S3, not S4 class system used to dispatch methods -- less RAM consumption by factor 7 (under 64 bit OS) -- faster operations by factor 4 to 2000 (under 64 bit OS) -- no slow-down of R's garbage collection (as caused by the pure existence of 'int64' objects) -- pure GPL, no copyrights from transnational commercial company - -While the advantage of the atomic S3 design over the complicated S4 object design is obvious, it is less obvious that an external package is the best way to enrich R with 64bit integers. An external package will not give us literals such as 1LL or directly allow us to address larger vectors than possible with base R. But it allows us to properly address larger vectors in other packages such as 'ff' or 'bigmemory' and it allows us to properly work with large surrogate keys from external databases. An external package realizing one data type also makes a perfect test bed to play with innovative performance enhancements. Performance tuned sorting and hashing are planned for the next release, which will give us fast versions of sort, order, merge, duplicated, unique, and table - for 64bit integers. - -For those who still hope that R's 'integer' will be 64bit some day, here is my key learning: migrating R's 'integer' from 32 to 64 bit would be RAM expensive. It would most likely require to also migrate R's 'double' from 64 to 128 bit - in order to again have a data type to which we can lossless coerce. The assumption that 'integer' is a proper subset of 'double' is scattered over R's semantics. We all expect that binary and n-ary functions such as '+' and 'c' do return 'double' and do not destroy information. With solely extending 64bit integers but not 128bit doubles, we have semantic changes potentially disappointing such expectations: integer64+double returns integer64 and does kill decimals. I did my best to make operations involving integer64 consistent and numerically stable - please consult the documentation at ?bit64 for details. - -Since this package is 'at risk' to create a lot of dependencies from other packages, I'd appreciate serious beta-testing and also code-review from the R-Core team. Please check the 'Limitations' sections at the help page and the numerics involving "long double" in C. If the conclusion is that this should be better done in Base R - I happly donate the code and drop this package. If we have to go with an external package for 64bit integers, it would be great if this work could convince the Rcpp team including Romain about the advantages of this approach. Shouldn't we join forces here? - -Best regards - -Jens Oehlschlägel -Munich, 11.2.2012 diff -Nru r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.9-Details.txt r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.9-Details.txt --- r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.9-Details.txt 2017-04-14 11:46:57.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.9-Details.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -I have used package 'bit64' as a testbed to explore a couple of approaches for implementing R's univariate algorithmic functionality efficiently. I have focused on single-threaded efficiency for two reasons: 1) Amdahl's law dictates that the more we parallelize, the more we depend on serial efficiency. 2) When working with truly big data it is not only absolute speed but also energy consumption that we care about. Under the hood package 'bit64' has multiple implementations of the same functionality, and high-level functions contain (yet simple heuristic) optimizers that choose among the available low-level functions. For example 'match' can choose between eight functions based on hashing or sorting/ordering. Function 'match' (and '%in%') has been accelerated by complementing lookup of 'x' in hashed 'table' by reverse lookup of 'table' in hashed 'x'. If 'x' is small and 'table' is big, reverse lookup avoids the cost of building a huge hashmap. As suggested in Simon Urbanek's package 'fastmatch', if 'match' is called multiple times with the same 'table', performance can be improved by re-using the hashmap implicitely built by 'match'. Beyond that, I have realized a couple of improvements: 1) Building the hashmap has now been singled out in a separate function 'hashmap' that explicitely returns an environment of class c("cache_integer64", "cache", "environment") containing the hashmap and some auxilliary data. 2) Instead of implicitely caching the hashmap as a side-effect when calling 'fastmatch', there are explicit functions for caching, for example 'hashcache' for attaching a cache with a hashmap, and 'remcache' for removing any cached data. 3) If the 'hashcache' function after hashing discovers that the number of unique values is much smaller than the total number of values, it will hash again using a much smaller hashmap: this typically saves a lot of RAM and accelerates usage of the hashmap because it reduces random access. 4) The cache layer has a mechanism for detecting outdated caches. This is even more important in the case of a cached hashmap, since R's typical hashmap only contains index pointers to the data, not the data itself (unlike in standard hashtables). As a result, an outdated cache might lead to a crash, if the data has changed since creation of the cached hashmap. The detection mechanism comes for free, since R does Copy-on-write and each change of a vector leads to memory reallocation: on each cache access we check for a modified vector address and remove the cache with a warning in case of a detected change. However, this method is of-course not failsafe in case of multiple changes. Therefore, until cache checking and removal is done in Base R, users using caching should carefully remove caches before modifying data. Users must also carefully remove caches before using functions that do in-place modifications such as 'ramsort', 'ramorder' and 'ramsortorder'. Users should also note that R's COPY-ON-MODIFY mechanism does more copying than one would expect: just reading from variable length arguments with the recommended 'list(...)' construct always copies the arguments and invalidates caches. For a workaround see the implementation of 'table.integer64'. 5) Beyond 'match', the package leverages speed gains of hashing or cached hashing for a couple of other high-level functions: '%in%', 'duplicated', 'unique', 'unipos' and 'table'. However, it turned out that only 'match', '%in%' and 'duplicated' benefit from a cached hashmap. For 'unique', 'unipos' and 'table' the cost of traversing an existing hashmap is as high as creating the hashmap from scratch. That leads to the undesireable effect that we need two implementations for each of these methods: one that simultaneously builds and uses the hashmap, and another that uses an existing hashmap (using the simultaneous method while a hashmap has been cached would duplicate RAM consumption). 6) Beyond leveraging hashing, all these high-level functions also have two low-level implementations that take advantage of (cached) ordering and (cached) sortordering instead (see order below). 6) Additional functions are implemented that benefit only from (cached) ordering and (cached) sortordering: 'sort', 'order', 'tiepos', 'keypos', 'rank', 'quantile' and dependants thereof ('median','summary','as.factor','as.ordered','table'). Method 'sort' is a cache-aware wrapper around 'ramsort', which depending on context chooses from multiple sorting algorithms (or from the cache): 'shellsort' (R's traditional inplace sorting algorithm), 'quicksort' (faster inplace), 'mergesort' (fast and stable), 'radixsort' (stable with linear scalability, for large datasets). The quicksort algorithm implemented here is in this context faster than the famous one of Bentley and McIllroy. It uses median of three random pivots and is like introsort protected against O(n^2) runtime (if a recursion limit is reached, it for now falls back to shellsort instead of heapsort). Function 'order.integer64' with option 'optimize = "memory"' calls 'ramorder' which chooses from a similar set of low-level algorithms. 'ramorder' - like in package 'ff' - is faster than ordering in Base R, but like 'order' in Base R still does the job by sorting index pointers to the data which creates heavy random access to the data. The novel 'ramsortorder' method realizes ordering close to the speed of sorting, by sorting index and data simultaneously and thereby avoiding heavy random access. Therefore the option 'optimize = "time"' is the default in 'order.integer64' and calls 'ramsortorder'. Function 'rank.integer64' implements only 'ties.method = "average"' and 'na.last="keep"' (the only sensible default, see e.g. 'cor'). Function 'prank.integer64' projects the values [min..max] via ranks [1..n] to [0..1]. 'qtile.integer64' is the inverse function of 'prank.integer64' and projects [0..1] to [min..max]. 'quantile.integer64' with 'type=0' and 'median.integer64' are convenience wrappers to 'qtile'. 'qtile' behaves very similar to 'quantile.default' with 'type=1' in that it only returns existing values, it is mostly symetric but it is using 'round' rather than 'floor'. Note that this implies that 'median.integer64' does not interpolate for even number of values (interpolation would create values that could not be represented as 64-bit integers). Function 'table.integer64' leverages hashing or sorting for counting frequencies of all unique values. This is by factor 3 slower than 'tabulate', but when called with 'return="list"' is by order of magnitude faster than 'table' (because 'table' wastes a lot of performance in large scale raw data manipulation before calling tabulate and in attaching the unique values as 'names' which loads heavy on the global string cache). When dealing with combinations of input vectors, 'table.integer64' can handle up to 2^63 hypothetical combinations and can return the existing combinations in a sparse format, whereas standard 'table' theoretically bails out at 2^31 (practically earlier due to RAM limitations) and insists on returning a full blown dense array. I compared the speed gains of hashing+usage versus sortordering+usage over a couple of univariate algorithmic operations: hashing and sortordering are competitive, with hashing rather winning for smaller and sortordering rather winning for larger vectors (due to better cache-obliviousness of sorting). The third option - ordering - is much slower, though competitive with Base R, and 50% RAM saving makes this an interesting option, especially when working with datasets close to the RAM limits. Though operations based on hashing can be faster than those on sortordering it is worth to note that if sortorder is cached, in most cases going with the sortorder-operation is faster than building the hashmap and using it. Thus sortordering seems a better RAM investement than hashing. It has the following advantages: - sortordering supports more functionality than hashing - sortordering gives better modularity (different from hashing, we can well separate *creating* and *using* the sortordering, because sorting permanently improves cache-locality) - without computational costs of keeping the original order ('keep.order=TRUE' in 'unique' and 'table'), sortorder gives sorted results while hashing gives random result order. If there are many unique values, fixing random order by sorting afterwards kills any performance benefit of hashing, compare for example the sequence {y <- unique(x); ind <- sort.list(y)} in 'factor'. - sorting better generalizes to very large data on disk compared to hashing - it is easier to lockfree parallelize sorting compared to hashing - creating the ordering quickly via sortordering and then caching only ordering (without the sorted data) is an interesting option to save RAM without too much speed loss - with ordering instead of sortordering there is an option to work with large borderline-sized datasets in-RAM These advantages of sorting over hashing are good news for my novel energy-efficient greeNsort® algorithms. The long term roadmap for packages 'bit64' and 'ff' is - demonstrate power of greeNsort® by accelerating integer64 sorting by yet another factor 2 - parallelization of important functions in bit64 - unifying the sort capabilities in ff with those in bit64 (logical, factor, integer, integer64, double) - generalizing the fast data management to all numeric data types (integer, integer64, double) - removing the 2^31-1 address limit in ff (rather using integer64 than double) - providing ff with proper disk sorting (reducing n*log(n) passes to 2 passes over the memory-mapped disk) © 2010-2012 Jens Oehlschlägel \ No newline at end of file diff -Nru r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.9.txt r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.9.txt --- r-cran-bit64-0.9-7.1/inst/ANNOUNCEMENT-0.9.txt 2017-04-14 11:44:51.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/ANNOUNCEMENT-0.9.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -Dear R community, - -The new version of package 'bit64' - which extends R with fast 64-bit integers - now has fast (single-threaded) implementations of the most important univariate algorithmic operations (those based on hashing and sorting). Package 'bit64' now has methods for 'match', '%in%', 'duplicated', 'unique', 'table', 'sort', 'order', 'rank', 'quantile', 'median' and 'summary'. Regarding data management it has novel generics 'unipos' (positions of the unique values), 'tiepos' (positions of ties), 'keypos' (positions of values in a sorted unique table) and derived methods 'as.factor' and 'as.ordered'. This 64-bit functionality is implemented carefully to be not slower than the respective 32-bit operations in Base R and also to avoid excessive execution times observed with 'order', 'rank' and 'table' (speedup factors 20/16/200 respective). This increases the dataset size with wich we can work truly interactive. The speed is achieved by simple heuristic optimizers: the mentioned high-level functions choose the best from multiple low-level algorithms and further take advantage of a novel optional caching method. In an example R session using a couple of these operations the 64-bit integers performed 22x faster than base 32-bit integers, hash-caching improved this to 24x amortized, sortorder-caching was most efficient with 38x (caching both, hashing and sorting is not worth it with 32x at duplicated RAM consumption). - -Since the package covers the most important functions for (univariate) data exploration and data management, I think it is now appropriate to claim that R has sound 64-bit integer support, for example for working with keys or counts imported from large databases. For details concerning approach, implementation and roadmap please check the ANNOUNCEMENT-0.9-Details.txt file and the package help files. - -Kind regards - - -Jens Oehlschlägel -Munich, 22.10.2012 diff -Nru r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.8.txt r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.8.txt --- r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.8.txt 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.8.txt 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1,26 @@ +Dear R-Core team, +Dear Rcpp team and other package teams, +Dear R users, + +The new package 'bit64' is available on CRAN for beta-testing and code-reviewing. + +Package 'bit64' provides fast serializable S3 atomic 64bit (signed) integers that can be used in vectors, matrices, arrays and data.frames. Methods are available for coercion from and to logicals, integers, doubles, characters as well as many elementwise and summary functions. + +Package 'bit64' has the following advantages over package 'int64' (which was sponsored by Google): +- true atomic vectors usable with length, dim, names etc. +- only S3, not S4 class system used to dispatch methods +- less RAM consumption by factor 7 (under 64 bit OS) +- faster operations by factor 4 to 2000 (under 64 bit OS) +- no slow-down of R's garbage collection (as caused by the pure existence of 'int64' objects) +- pure GPL, no copyrights from transnational commercial company + +While the advantage of the atomic S3 design over the complicated S4 object design is obvious, it is less obvious that an external package is the best way to enrich R with 64bit integers. An external package will not give us literals such as 1LL or directly allow us to address larger vectors than possible with base R. But it allows us to properly address larger vectors in other packages such as 'ff' or 'bigmemory' and it allows us to properly work with large surrogate keys from external databases. An external package realizing one data type also makes a perfect test bed to play with innovative performance enhancements. Performance tuned sorting and hashing are planned for the next release, which will give us fast versions of sort, order, merge, duplicated, unique, and table - for 64bit integers. + +For those who still hope that R's 'integer' will be 64bit some day, here is my key learning: migrating R's 'integer' from 32 to 64 bit would be RAM expensive. It would most likely require to also migrate R's 'double' from 64 to 128 bit - in order to again have a data type to which we can lossless coerce. The assumption that 'integer' is a proper subset of 'double' is scattered over R's semantics. We all expect that binary and n-ary functions such as '+' and 'c' do return 'double' and do not destroy information. With solely extending 64bit integers but not 128bit doubles, we have semantic changes potentially disappointing such expectations: integer64+double returns integer64 and does kill decimals. I did my best to make operations involving integer64 consistent and numerically stable - please consult the documentation at ?bit64 for details. + +Since this package is 'at risk' to create a lot of dependencies from other packages, I'd appreciate serious beta-testing and also code-review from the R-Core team. Please check the 'Limitations' sections at the help page and the numerics involving "long double" in C. If the conclusion is that this should be better done in Base R - I happly donate the code and drop this package. If we have to go with an external package for 64bit integers, it would be great if this work could convince the Rcpp team including Romain about the advantages of this approach. Shouldn't we join forces here? + +Best regards + +Jens Oehlschlägel +Munich, 11.2.2012 diff -Nru r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.9-Details.txt r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.9-Details.txt --- r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.9-Details.txt 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.9-Details.txt 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1 @@ +I have used package 'bit64' as a testbed to explore a couple of approaches for implementing R's univariate algorithmic functionality efficiently. I have focused on single-threaded efficiency for two reasons: 1) Amdahl's law dictates that the more we parallelize, the more we depend on serial efficiency. 2) When working with truly big data it is not only absolute speed but also energy consumption that we care about. Under the hood package 'bit64' has multiple implementations of the same functionality, and high-level functions contain (yet simple heuristic) optimizers that choose among the available low-level functions. For example 'match' can choose between eight functions based on hashing or sorting/ordering. Function 'match' (and '%in%') has been accelerated by complementing lookup of 'x' in hashed 'table' by reverse lookup of 'table' in hashed 'x'. If 'x' is small and 'table' is big, reverse lookup avoids the cost of building a huge hashmap. As suggested in Simon Urbanek's package 'fastmatch', if 'match' is called multiple times with the same 'table', performance can be improved by re-using the hashmap implicitely built by 'match'. Beyond that, I have realized a couple of improvements: 1) Building the hashmap has now been singled out in a separate function 'hashmap' that explicitely returns an environment of class c("cache_integer64", "cache", "environment") containing the hashmap and some auxilliary data. 2) Instead of implicitely caching the hashmap as a side-effect when calling 'fastmatch', there are explicit functions for caching, for example 'hashcache' for attaching a cache with a hashmap, and 'remcache' for removing any cached data. 3) If the 'hashcache' function after hashing discovers that the number of unique values is much smaller than the total number of values, it will hash again using a much smaller hashmap: this typically saves a lot of RAM and accelerates usage of the hashmap because it reduces random access. 4) The cache layer has a mechanism for detecting outdated caches. This is even more important in the case of a cached hashmap, since R's typical hashmap only contains index pointers to the data, not the data itself (unlike in standard hashtables). As a result, an outdated cache might lead to a crash, if the data has changed since creation of the cached hashmap. The detection mechanism comes for free, since R does Copy-on-write and each change of a vector leads to memory reallocation: on each cache access we check for a modified vector address and remove the cache with a warning in case of a detected change. However, this method is of-course not failsafe in case of multiple changes. Therefore, until cache checking and removal is done in Base R, users using caching should carefully remove caches before modifying data. Users must also carefully remove caches before using functions that do in-place modifications such as 'ramsort', 'ramorder' and 'ramsortorder'. Users should also note that R's COPY-ON-MODIFY mechanism does more copying than one would expect: just reading from variable length arguments with the recommended 'list(...)' construct always copies the arguments and invalidates caches. For a workaround see the implementation of 'table.integer64'. 5) Beyond 'match', the package leverages speed gains of hashing or cached hashing for a couple of other high-level functions: '%in%', 'duplicated', 'unique', 'unipos' and 'table'. However, it turned out that only 'match', '%in%' and 'duplicated' benefit from a cached hashmap. For 'unique', 'unipos' and 'table' the cost of traversing an existing hashmap is as high as creating the hashmap from scratch. That leads to the undesireable effect that we need two implementations for each of these methods: one that simultaneously builds and uses the hashmap, and another that uses an existing hashmap (using the simultaneous method while a hashmap has been cached would duplicate RAM consumption). 6) Beyond leveraging hashing, all these high-level functions also have two low-level implementations that take advantage of (cached) ordering and (cached) sortordering instead (see order below). 6) Additional functions are implemented that benefit only from (cached) ordering and (cached) sortordering: 'sort', 'order', 'tiepos', 'keypos', 'rank', 'quantile' and dependants thereof ('median','summary','as.factor','as.ordered','table'). Method 'sort' is a cache-aware wrapper around 'ramsort', which depending on context chooses from multiple sorting algorithms (or from the cache): 'shellsort' (R's traditional inplace sorting algorithm), 'quicksort' (faster inplace), 'mergesort' (fast and stable), 'radixsort' (stable with linear scalability, for large datasets). The quicksort algorithm implemented here is in this context faster than the famous one of Bentley and McIllroy. It uses median of three random pivots and is like introsort protected against O(n^2) runtime (if a recursion limit is reached, it for now falls back to shellsort instead of heapsort). Function 'order.integer64' with option 'optimize = "memory"' calls 'ramorder' which chooses from a similar set of low-level algorithms. 'ramorder' - like in package 'ff' - is faster than ordering in Base R, but like 'order' in Base R still does the job by sorting index pointers to the data which creates heavy random access to the data. The novel 'ramsortorder' method realizes ordering close to the speed of sorting, by sorting index and data simultaneously and thereby avoiding heavy random access. Therefore the option 'optimize = "time"' is the default in 'order.integer64' and calls 'ramsortorder'. Function 'rank.integer64' implements only 'ties.method = "average"' and 'na.last="keep"' (the only sensible default, see e.g. 'cor'). Function 'prank.integer64' projects the values [min..max] via ranks [1..n] to [0..1]. 'qtile.integer64' is the inverse function of 'prank.integer64' and projects [0..1] to [min..max]. 'quantile.integer64' with 'type=0' and 'median.integer64' are convenience wrappers to 'qtile'. 'qtile' behaves very similar to 'quantile.default' with 'type=1' in that it only returns existing values, it is mostly symetric but it is using 'round' rather than 'floor'. Note that this implies that 'median.integer64' does not interpolate for even number of values (interpolation would create values that could not be represented as 64-bit integers). Function 'table.integer64' leverages hashing or sorting for counting frequencies of all unique values. This is by factor 3 slower than 'tabulate', but when called with 'return="list"' is by order of magnitude faster than 'table' (because 'table' wastes a lot of performance in large scale raw data manipulation before calling tabulate and in attaching the unique values as 'names' which loads heavy on the global string cache). When dealing with combinations of input vectors, 'table.integer64' can handle up to 2^63 hypothetical combinations and can return the existing combinations in a sparse format, whereas standard 'table' theoretically bails out at 2^31 (practically earlier due to RAM limitations) and insists on returning a full blown dense array. I compared the speed gains of hashing+usage versus sortordering+usage over a couple of univariate algorithmic operations: hashing and sortordering are competitive, with hashing rather winning for smaller and sortordering rather winning for larger vectors (due to better cache-obliviousness of sorting). The third option - ordering - is much slower, though competitive with Base R, and 50% RAM saving makes this an interesting option, especially when working with datasets close to the RAM limits. Though operations based on hashing can be faster than those on sortordering it is worth to note that if sortorder is cached, in most cases going with the sortorder-operation is faster than building the hashmap and using it. Thus sortordering seems a better RAM investement than hashing. It has the following advantages: - sortordering supports more functionality than hashing - sortordering gives better modularity (different from hashing, we can well separate *creating* and *using* the sortordering, because sorting permanently improves cache-locality) - without computational costs of keeping the original order ('keep.order=TRUE' in 'unique' and 'table'), sortorder gives sorted results while hashing gives random result order. If there are many unique values, fixing random order by sorting afterwards kills any performance benefit of hashing, compare for example the sequence {y <- unique(x); ind <- sort.list(y)} in 'factor'. - sorting better generalizes to very large data on disk compared to hashing - it is easier to lockfree parallelize sorting compared to hashing - creating the ordering quickly via sortordering and then caching only ordering (without the sorted data) is an interesting option to save RAM without too much speed loss - with ordering instead of sortordering there is an option to work with large borderline-sized datasets in-RAM These advantages of sorting over hashing are good news for my novel energy-efficient greeNsort® algorithms. The long term roadmap for packages 'bit64' and 'ff' is - demonstrate power of greeNsort® by accelerating integer64 sorting by yet another factor 2 - parallelization of important functions in bit64 - unifying the sort capabilities in ff with those in bit64 (logical, factor, integer, integer64, double) - generalizing the fast data management to all numeric data types (integer, integer64, double) - removing the 2^31-1 address limit in ff (rather using integer64 than double) - providing ff with proper disk sorting (reducing n*log(n) passes to 2 passes over the memory-mapped disk) © 2010-2012 Jens Oehlschlägel \ No newline at end of file diff -Nru r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.9.txt r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.9.txt --- r-cran-bit64-0.9-7.1/inst/doc/ANNOUNCEMENT-0.9.txt 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/doc/ANNOUNCEMENT-0.9.txt 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1,11 @@ +Dear R community, + +The new version of package 'bit64' - which extends R with fast 64-bit integers - now has fast (single-threaded) implementations of the most important univariate algorithmic operations (those based on hashing and sorting). Package 'bit64' now has methods for 'match', '%in%', 'duplicated', 'unique', 'table', 'sort', 'order', 'rank', 'quantile', 'median' and 'summary'. Regarding data management it has novel generics 'unipos' (positions of the unique values), 'tiepos' (positions of ties), 'keypos' (positions of values in a sorted unique table) and derived methods 'as.factor' and 'as.ordered'. This 64-bit functionality is implemented carefully to be not slower than the respective 32-bit operations in Base R and also to avoid excessive execution times observed with 'order', 'rank' and 'table' (speedup factors 20/16/200 respective). This increases the dataset size with wich we can work truly interactive. The speed is achieved by simple heuristic optimizers: the mentioned high-level functions choose the best from multiple low-level algorithms and further take advantage of a novel optional caching method. In an example R session using a couple of these operations the 64-bit integers performed 22x faster than base 32-bit integers, hash-caching improved this to 24x amortized, sortorder-caching was most efficient with 38x (caching both, hashing and sorting is not worth it with 32x at duplicated RAM consumption). + +Since the package covers the most important functions for (univariate) data exploration and data management, I think it is now appropriate to claim that R has sound 64-bit integer support, for example for working with keys or counts imported from large databases. For details concerning approach, implementation and roadmap please check the ANNOUNCEMENT-0.9-Details.txt file and the package help files. + +Kind regards + + +Jens Oehlschlägel +Munich, 22.10.2012 diff -Nru r-cran-bit64-0.9-7.1/inst/doc/README_devel.txt r-cran-bit64-4.0.5/inst/doc/README_devel.txt --- r-cran-bit64-0.9-7.1/inst/doc/README_devel.txt 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/doc/README_devel.txt 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1,10 @@ +Naming conventions +================== +R/*.R R files (including .Rd comments) +src/*.c C files +man/*.Rd Automatically generated Rd. files, do not modify + +Rd api +====== +prebuild.sh call manually for generating all .Rd files from the .Rd comments in the R files with the help of +exec/make_rd.pl converts "#! lines" in R/*.R files into man/.Rd files, where is derived from the "#! \name{}" in the first line diff -Nru r-cran-bit64-0.9-7.1/inst/README_devel.txt r-cran-bit64-4.0.5/inst/README_devel.txt --- r-cran-bit64-0.9-7.1/inst/README_devel.txt 2017-04-14 11:45:30.000000000 +0000 +++ r-cran-bit64-4.0.5/inst/README_devel.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -Naming conventions -================== -R/*.R R files (including .Rd comments) -src/*.c C files -man/*.Rd Automatically generated Rd. files, do not modify - -Rd api -====== -prebuild.sh call manually for generating all .Rd files from the .Rd comments in the R files with the help of -exec/make_rd.pl converts "#! lines" in R/*.R files into man/.Rd files, where is derived from the "#! \name{}" in the first line diff -Nru r-cran-bit64-0.9-7.1/man/all.equal.integer64.rd r-cran-bit64-4.0.5/man/all.equal.integer64.rd --- r-cran-bit64-0.9-7.1/man/all.equal.integer64.rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/man/all.equal.integer64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1,72 @@ +\name{all.equal.integer64} +\alias{all.equal.integer64} +\title{ + Test if two integer64 vectors are all.equal +} +\description{ + A utility to compare integer64 objects 'x' and 'y' testing for ‘near equality’, see \code{\link{all.equal}}. +} +\usage{ + \method{all.equal}{integer64}( + target +, current +, tolerance = sqrt(.Machine$double.eps) +, scale = NULL +, countEQ = FALSE +, formatFUN = function(err, what) format(err) +, ... +, check.attributes = TRUE +) +} +\arguments{ + \item{target}{ a vector of 'integer64' or an object that can be coerced with \code{\link{as.integer64}} } + \item{current}{ a vector of 'integer64' or an object that can be coerced with \code{\link{as.integer64}} } + \item{tolerance}{numeric \eqn{\ge} 0. Differences smaller than + \code{tolerance} are not reported. The default value is close to + \code{1.5e-8}.} + \item{scale}{\code{NULL} or numeric > 0, typically of length 1 or + \code{length(target)}. See \sQuote{Details}.} + \item{countEQ}{logical indicating if the \code{target == current} + cases should be counted when computing the mean (absolute or + relative) differences. The default, \code{FALSE} may seem + misleading in cases where \code{target} and \code{current} only + differ in a few places; see the extensive example.} + \item{formatFUN}{a \code{\link{function}} of two arguments, + \code{err}, the relative, absolute or scaled error, and + \code{what}, a character string indicating the \emph{kind} of error; + maybe used, e.g., to format relative and absolute errors differently.} + \item{\dots}{further arguments are ignored} + \item{check.attributes}{logical indicating if the + \code{\link{attributes}} of \code{target} and \code{current} + (other than the names) should be compared.} +} +\value{ + Either ‘TRUE’ (‘NULL’ for ‘attr.all.equal’) or a vector of ‘mode’ + ‘"character"’ describing the differences between ‘target’ and + ‘current’. +} +\details{ + In \code{\link{all.equal.numeric}} the type \code{integer} is treated as a proper subset of \code{double} + i.e. does not complain about comparing \code{integer} with \code{double}. + Following this logic \code{all.equal.integer64} treats \code{integer} as a proper subset of \code{integer64} + and does not complain about comparing \code{integer} with \code{integer64}. \code{double} also compares without warning + as long as the values are within \code{\link{lim.integer64}}, if \code{double} are bigger \code{all.equal.integer64} + complains about the \code{all.equal.integer64 overflow warning}. For further details see \code{\link{all.equal}}. +} +\note{ + \code{\link{all.equal}} only dispatches to this method if the first argument is \code{integer64}, + calling \code{\link{all.equal}} with a \code{non-integer64} first and a \code{integer64} second argument + gives undefined behavior! +} +\author{ + Leonardo Silvestri (for package nanotime) +} +\seealso{ + \code{\link{all.equal}} +} +\examples{ + all.equal(as.integer64(1:10), as.integer64(0:9)) + all.equal(as.integer64(1:10), as.integer(1:10)) + all.equal(as.integer64(1:10), as.double(1:10)) + all.equal(as.integer64(1), as.double(1e300)) +} diff -Nru r-cran-bit64-0.9-7.1/man/as.character.integer64.rd r-cran-bit64-4.0.5/man/as.character.integer64.rd --- r-cran-bit64-0.9-7.1/man/as.character.integer64.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/as.character.integer64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -4,6 +4,7 @@ \alias{as.integer.integer64} \alias{as.logical.integer64} \alias{as.bitstring} +\alias{print.bitstring} \alias{as.bitstring.integer64} \alias{as.factor.integer64} \alias{as.ordered.integer64} @@ -19,6 +20,7 @@ \usage{ as.bitstring(x, \dots) \method{as.bitstring}{integer64}(x, \dots) + \method{print}{bitstring}(x, \dots) \method{as.character}{integer64}(x, \dots) \method{as.double}{integer64}(x, keep.names = FALSE, \dots) \method{as.integer}{integer64}(x, \dots) @@ -32,7 +34,7 @@ \item{\dots}{ further arguments to the \code{\link{NextMethod}} } } \value{ - \code{as.bitstring} returns a string of . \cr + \code{as.bitstring} returns a string of class 'bitstring'. \cr The other methods return atomic vectors of the expected types } \author{ @@ -44,4 +46,7 @@ \examples{ as.character(lim.integer64()) as.bitstring(lim.integer64()) + as.bitstring(as.integer64(c( + -2,-1,NA,0:2 + ))) } diff -Nru r-cran-bit64-0.9-7.1/man/as.integer64.character.rd r-cran-bit64-4.0.5/man/as.integer64.character.rd --- r-cran-bit64-0.9-7.1/man/as.integer64.character.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/as.integer64.character.rd 2020-06-14 15:15:59.000000000 +0000 @@ -2,6 +2,7 @@ \alias{as.integer64} \alias{as.integer64.integer64} \alias{as.integer64.NULL} +\alias{as.integer64.bitstring} \alias{as.integer64.character} \alias{as.integer64.double} \alias{as.integer64.integer} @@ -20,6 +21,7 @@ \method{as.integer64}{integer64}(x, \dots) \method{as.integer64}{NULL}(x, \dots) \method{as.integer64}{character}(x, \dots) + \method{as.integer64}{bitstring}(x, \dots) \method{as.integer64}{double}(x, keep.names = FALSE, \dots) \method{as.integer64}{integer}(x, \dots) \method{as.integer64}{logical}(x, \dots) @@ -32,7 +34,12 @@ } \details{ \code{as.integer64.character} is realized using C function \code{strtoll} which does not support scientific notation. - Instead of '1e6' use '1000000'. + Instead of '1e6' use '1000000'. + \code{as.integer64.bitstring} evaluates characters '0' anbd ' ' as zero-bit, + all other one byte characters as one-bit, + multi-byte characters are not allowed, + strings shorter than 64 characters are treated as if they were left-padded with '0', + strings longer than 64 bytes are mapped to \code{NA_INTEGER64} and a warning is emitted. } \value{ The other methods return atomic vectors of the expected types @@ -44,5 +51,23 @@ \keyword{ manip } \seealso{ \code{\link{as.character.integer64}} \code{\link{integer64}} } \examples{ - as.integer64(as.character(lim.integer64())) +as.integer64(as.character(lim.integer64())) +as.integer64( + structure(c("1111111111111111111111111111111111111111111111111111111111111110", + "1111111111111111111111111111111111111111111111111111111111111111", + "1000000000000000000000000000000000000000000000000000000000000000", + "0000000000000000000000000000000000000000000000000000000000000000", + "0000000000000000000000000000000000000000000000000000000000000001", + "0000000000000000000000000000000000000000000000000000000000000010" + ), class = "bitstring") +) +as.integer64( + structure(c("............................................................... ", + "................................................................", + ". ", + "", + ".", + "10" + ), class = "bitstring") +) } diff -Nru r-cran-bit64-0.9-7.1/man/bit64-package.rd r-cran-bit64-4.0.5/man/bit64-package.rd --- r-cran-bit64-0.9-7.1/man/bit64-package.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/bit64-package.rd 2020-07-31 16:11:34.000000000 +0000 @@ -101,8 +101,8 @@ to new or old vectors, which helps to avoid unnecessary memory allocation, unnecessary copying and unnessary garbage collection. Prior to 0.93 \emph{within} our R functions we also deviated from conventional R programming by not using \code{\link{attr<-}} and \code{\link{attributes<-}} because they always did new memory allocation and copying in older R versions. If we wanted to set attributes of return values that we have freshly created, - we instead used functions \code{\link[bit]{setattr}} and \code{\link[bit]{setattributes}} from package \code{\link[bit]{bit}}. - From version 0.93 \code{\link[bit]{setattr}} is only used for manipulating \code{\link{cache}} objects, in \code{\link{ramsort.integer64}} and \code{\link{sort.integer64}} and in \code{\link{as.data.frame.integer64}}. + we instead used functions \code{\link[bit:getsetattr]{setattr}} and \code{\link[bit:getsetattr]{setattributes}} from package \code{\link[bit]{bit}}. + From version 0.93 \code{\link[bit:getsetattr]{setattr}} is only used for manipulating \code{\link{cache}} objects, in \code{\link{ramsort.integer64}} and \code{\link{sort.integer64}} and in \code{\link{as.data.frame.integer64}}. } \section{Arithmetic precision and coercion}{ The fact that we introduce 64 bit long long integers -- without introducing 128-bit long doubles -- creates some subtle challenges: @@ -156,7 +156,7 @@ The methods \code{\link{is.integer64}} and \code{\link{is.vector}} both return \code{TRUE} for \code{integer64}. Note that we did not patch \code{\link{storage.mode}} and \code{\link{typeof}}, which both continue returning 'double' Like for 32 bit \code{\link{integer}}, \code{\link{mode}} returns 'numeric' and \code{\link{as.double}}) tries coercing to \code{\link{double}}). - It is likely that 'integer64' becomes a \code{\link[ff]{vmode}} in package \code{\link[ff]{ff}}. + It is possible that 'integer64' becomes a \code{vmode} in package \code{ff}. \cr Further methods for creating \code{integer64} are \code{\link[=range.integer64]{range}} which returns the range of the data type if calles without arguments, \code{\link[=rep.integer64]{rep}}, \code{\link[=seq.integer64]{seq}}. @@ -168,6 +168,7 @@ \bold{creating,testing,printing} \tab \bold{see also} \tab \bold{description} \cr \code{NA_integer64_} \tab \code{\link{NA_integer_}} \tab NA constant \cr \code{integer64} \tab \code{\link{integer}} \tab create zero atomic vector \cr + \code{\link{runif64}} \tab \code{\link{runif}} \tab create random vector \cr \code{\link{rep.integer64}} \tab \code{\link{rep}} \tab \cr \code{\link{seq.integer64}} \tab \code{\link{seq}} \tab \cr \code{\link{is.integer64}} \tab \code{\link{is}} \tab \cr @@ -189,6 +190,7 @@ \cr \bold{coercing to integer64} \tab \bold{see also} \tab \bold{description} \cr \code{\link{as.integer64}} \tab \tab generic \cr + \code{\link{as.integer64.bitstring}} \tab \code{\link{as.bitstring}} \tab \cr \code{\link{as.integer64.character}} \tab \code{\link{character}} \tab \cr \code{\link{as.integer64.double}} \tab \code{\link{double}} \tab \cr \code{\link{as.integer64.integer}} \tab \code{\link{integer}} \tab \cr @@ -290,6 +292,7 @@ \code{\link{quantile.integer64}} \tab \code{\link{quantile}} \tab (existing) values at specified percentiles (/s/o/so) \cr \code{\link{median.integer64}} \tab \code{\link{median}} \tab (existing) value at percentile 0.5 (/s/o/so) \cr \code{\link{summary.integer64}} \tab \code{\link{summary}} \tab (/s/o/so) \cr + \code{\link{all.equal.integer64}} \tab \code{\link{all.equal}} \tab test if two objects are (nearly) equal (/s/o/so) \cr \cr \bold{helper functions} \tab \bold{see also} \tab \bold{description} \cr \code{\link{minusclass}} \tab \code{\link{minusclass}} \tab removing class attritbute \cr @@ -310,7 +313,7 @@ \section{Limitations inherited from implementing 64 bit integers via an external package}{ \itemize{ \item \bold{vector size} of atomic vectors is still limited to \code{\link{.Machine}$integer.max}. - However, external memory extending packages such as \code{\link[ff]{ff}} or \code{bigmemory} + However, external memory extending packages such as \code{ff} or \code{bigmemory} can extend their address space now with \code{integer64}. Having 64 bit integers also help with those not so obvious address issues that arise once we exchange data with SQL databases and datawarehouses, which use big integers as surrogate keys, e.g. on indexed primary key columns. diff -Nru r-cran-bit64-0.9-7.1/man/bit64S3.rd r-cran-bit64-4.0.5/man/bit64S3.rd --- r-cran-bit64-0.9-7.1/man/bit64S3.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/bit64S3.rd 2020-06-14 15:15:59.000000000 +0000 @@ -1,114 +1,114 @@ -\name{bit64S3} -\alias{bit64S3} -\alias{:} -\alias{:.default} -\alias{:.integer64} -\alias{is.double} -\alias{is.double.default} -\alias{is.double.integer64} -\alias{match} -\alias{match.default} -\alias{\%in\%} -\alias{\%in\%.default} -\alias{rank} -\alias{rank.default} -%\alias{table} -%\alias{table.default} -\alias{order} -\alias{order.default} -\title{ - Tunrning base R functions into S3 generics for bit64 -} -\description{ - Turn those base functions S3 generic which are used in bit64 -} -\usage{ - from:to - #--as-cran complains about \method{:}{default}(from, to) - #--as-cran complains about \method{:}{integer64}(from, to) - is.double(x) - \method{is.double}{default}(x) - \method{is.double}{integer64}(x) - match(x, table, ...) - \method{match}{default}(x, table, ...) - x \%in\% table - \method{\%in\%}{default}(x, table) - rank(x, ...) - \method{rank}{default}(x, ...) - %table(...) - %\method{table}{default}(...) - order(...) - \method{order}{default}(...) -} -\arguments{ - \item{x}{ - integer64 vector: the values to be matched, optionally carrying a cache created with \code{\link{hashcache}} -} - \item{table}{ - integer64 vector: the values to be matched against, optionally carrying a cache created with \code{\link{hashcache}} or \code{\link{sortordercache}} -} - \item{from}{ scalar denoting first element of sequence } - \item{to}{ scalar denoting last element of sequence } - \item{\dots}{ ignored } -} -\details{ - The following functions are turned into S3 gernerics in order to dispatch methods for \code{\link{integer64}}: - \preformatted{ - \code{\link{:}} - \code{\link{is.double}} - \code{\link{match}} - \code{\link{\%in\%}} - %\code{\link{table}} - \code{\link{rank}} - \code{\link{order}} - } -} -\value{ - \code{\link{invisible}} -} -\author{ -Jens Oehlschlägel -} -\note{ - \code{\link{is.double}} returns \code{FALSE} for \code{\link{integer64}} \cr - \code{\link{:}} currently only dispatches at its first argument, thus \code{as.integer64(1):9} works but \code{1:as.integer64(9)} doesn't - \code{\link{match}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{match(2, as.integer64(0:3))} - \code{\link{\%in\%}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{2 \%in\% as.integer64(0:3)} - \code{\link{order}} currently only orders a single argument, trying more than one raises an error -} -\seealso{ - \code{\link{bit64}}, \code{\link{S3}} -} -\examples{ - is.double(as.integer64(1)) - as.integer64(1):9 - match(as.integer64(2), as.integer64(0:3)) - as.integer64(2) \%in\% as.integer64(0:3) - - unique(as.integer64(c(1,1,2))) - rank(as.integer64(c(1,1,2))) - - %table(as.integer64(c(1,1,2))) - %table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))) - %table(as.integer64(c(1,1,2)),c(3,4,4)) - %table(c(1,1,2),as.integer64(c(3,4,4))) - - order(as.integer64(c(1,NA,2))) - - \dontshow{ - stopifnot(identical(match(as.integer64(2), as.integer64(0:3)), match(2, 0:3))) - stopifnot(identical(as.integer64(2) \%in\% as.integer64(0:3), 2 \%in\% 0:3)) - - stopifnot(identical(unique(as.integer64(c(1,1,2))), as.integer64(unique(c(1,1,2))))) - stopifnot(identical(rank(as.integer64(c(1,1,2))), rank(c(1,1,2)))) - - %stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2)))) - %stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) - %stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4)))) - %stopifnot(identical(table(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) - - stopifnot(identical(order(as.integer64(c(1,NA,2))), order(c(1,NA,2)))) - stopifnot(identical(order(as.integer64(c(1,NA,2)), decreasing=TRUE), order(c(1,NA,2), decreasing=TRUE))) - } -} -\keyword{ methods } +\name{bit64S3} +\alias{bit64S3} +\alias{:} +\alias{:.default} +\alias{:.integer64} +\alias{is.double} +\alias{is.double.default} +\alias{is.double.integer64} +\alias{match} +\alias{match.default} +\alias{\%in\%} +\alias{\%in\%.default} +\alias{rank} +\alias{rank.default} +%\alias{table} +%\alias{table.default} +\alias{order} +\alias{order.default} +\title{ + Turning base R functions into S3 generics for bit64 +} +\description{ + Turn those base functions S3 generic which are used in bit64 +} +\usage{ + from:to + #--as-cran complains about \method{:}{default}(from, to) + #--as-cran complains about \method{:}{integer64}(from, to) + is.double(x) + \method{is.double}{default}(x) + \method{is.double}{integer64}(x) + match(x, table, ...) + \method{match}{default}(x, table, ...) + x \%in\% table + \method{\%in\%}{default}(x, table) + rank(x, ...) + \method{rank}{default}(x, ...) + %table(...) + %\method{table}{default}(...) + order(...) + \method{order}{default}(...) +} +\arguments{ + \item{x}{ + integer64 vector: the values to be matched, optionally carrying a cache created with \code{\link{hashcache}} +} + \item{table}{ + integer64 vector: the values to be matched against, optionally carrying a cache created with \code{\link{hashcache}} or \code{\link{sortordercache}} +} + \item{from}{ scalar denoting first element of sequence } + \item{to}{ scalar denoting last element of sequence } + \item{\dots}{ ignored } +} +\details{ + The following functions are turned into S3 gernerics in order to dispatch methods for \code{\link{integer64}}: + \preformatted{ + \code{\link{:}} + \code{\link{is.double}} + \code{\link{match}} + \code{\link{\%in\%}} + %\code{\link{table}} + \code{\link{rank}} + \code{\link{order}} + } +} +\value{ + \code{\link{invisible}} +} +\author{ +Jens Oehlschlägel +} +\note{ + \code{\link{is.double}} returns \code{FALSE} for \code{\link{integer64}} \cr + \code{\link{:}} currently only dispatches at its first argument, thus \code{as.integer64(1):9} works but \code{1:as.integer64(9)} doesn't + \code{\link{match}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{match(2, as.integer64(0:3))} + \code{\link{\%in\%}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{2 \%in\% as.integer64(0:3)} + \code{\link{order}} currently only orders a single argument, trying more than one raises an error +} +\seealso{ + \code{\link{bit64}}, \code{\link{S3}} +} +\examples{ + is.double(as.integer64(1)) + as.integer64(1):9 + match(as.integer64(2), as.integer64(0:3)) + as.integer64(2) \%in\% as.integer64(0:3) + + unique(as.integer64(c(1,1,2))) + rank(as.integer64(c(1,1,2))) + + %table(as.integer64(c(1,1,2))) + %table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))) + %table(as.integer64(c(1,1,2)),c(3,4,4)) + %table(c(1,1,2),as.integer64(c(3,4,4))) + + order(as.integer64(c(1,NA,2))) + + \dontshow{ + stopifnot(identical(match(as.integer64(2), as.integer64(0:3)), match(2, 0:3))) + stopifnot(identical(as.integer64(2) \%in\% as.integer64(0:3), 2 \%in\% 0:3)) + + stopifnot(identical(unique(as.integer64(c(1,1,2))), as.integer64(unique(c(1,1,2))))) + stopifnot(identical(rank(as.integer64(c(1,1,2))), rank(c(1,1,2)))) + + %stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2)))) + %stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) + %stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4)))) + %stopifnot(identical(table(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) + + stopifnot(identical(order(as.integer64(c(1,NA,2))), order(c(1,NA,2)))) + stopifnot(identical(order(as.integer64(c(1,NA,2)), decreasing=TRUE), order(c(1,NA,2), decreasing=TRUE))) + } +} +\keyword{ methods } diff -Nru r-cran-bit64-0.9-7.1/man/cache.rd r-cran-bit64-4.0.5/man/cache.rd --- r-cran-bit64-0.9-7.1/man/cache.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/cache.rd 2020-06-14 15:15:59.000000000 +0000 @@ -6,7 +6,6 @@ \alias{getcache} \alias{remcache} \alias{print.cache} -\alias{still.identical} \title{ Atomic Caching } @@ -21,15 +20,11 @@ getcache(x, which) remcache(x) \method{print}{cache}(x, all.names = FALSE, pattern, \dots) -still.identical(x, y) } \arguments{ \item{x}{ an integer64 vector (or a cache object in case of \code{print.cache}) } - \item{y}{ - an integer64 vector -} \item{which}{ A character naming the object to be retrieved from the cache or to be stored in the cache } @@ -50,7 +45,6 @@ A \code{cache} is an \code{link{environment}} attached to an atomic object with the \code{link{attrib}} name 'cache'. It contains at least a reference to the atomic object that carries the cache. This is used when accessing the cache to detect whether the object carrying the cache has been modified meanwhile. - Function \code{still.identical(x,y)} checks whether the objects \code{x} and \code{y} \cr Function \code{newcache(x)} creates a new cache referencing \code{x} \cr Function \code{jamcache(x)} forces \code{x} to have a cache \cr Function \code{cache(x)} returns the cache attached to \code{x} if it is not found to be outdated \cr @@ -65,6 +59,7 @@ Jens Oehlschlägel } \seealso{ + \code{\link{still.identical}} for testing whether to symbols point to the same RAM. \cr Functions that get and set small cache-content automatically when a cache is present: \code{\link{na.count}}, \code{\link{nvalid}}, \code{\link{is.sorted}}, \code{\link{nunique}} and \code{\link{nties}} \cr Setting big caches with a relevant memory footprint requires a conscious decision of the user: \code{\link{hashcache}}, \code{\link{sortcache}}, \code{\link{ordercache}} and \code{\link{sortordercache}} \cr Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{as.factor.integer64}}, \code{\link{as.ordered.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr diff -Nru r-cran-bit64-0.9-7.1/man/extract.replace.integer64.rd r-cran-bit64-4.0.5/man/extract.replace.integer64.rd --- r-cran-bit64-0.9-7.1/man/extract.replace.integer64.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/extract.replace.integer64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -10,13 +10,14 @@ Methods to extract and replace parts of an integer64 vector. } \usage{ - \method{[}{integer64}(x, \dots) + \method{[}{integer64}(x, i, \dots) \method{[}{integer64}(x, \dots) <- value \method{[[}{integer64}(x, \dots) \method{[[}{integer64}(x, \dots) <- value } \arguments{ \item{x}{ an atomic vector } + \item{i}{ indices specifying elements to extract } \item{value}{ an atomic vector with values to be assigned } \item{\dots}{ further arguments to the \code{\link{NextMethod}} } } @@ -40,4 +41,8 @@ x x[] x[,2:3] + \dontshow{ + r <- c(runif64(1e3, lim.integer64()[1], lim.integer64()[2]), NA, -2:2) + stopifnot(identical(r, as.integer64(as.bitstring(r)))) + } } diff -Nru r-cran-bit64-0.9-7.1/man/format.integer64.rd r-cran-bit64-4.0.5/man/format.integer64.rd --- r-cran-bit64-0.9-7.1/man/format.integer64.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/format.integer64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -69,4 +69,12 @@ \seealso{ \code{\link{xor.integer64}} \code{\link{integer64}} } \examples{ sqrt(as.integer64(1:12)) +\dontshow{ +i <- -999:999 +for (s in -3:3){ +r <- as.integer64(round(as.integer(i), s)) + r64 <- round(as.integer64(i), s) + stopifnot(identical(r,r64)) +} +} } diff -Nru r-cran-bit64-0.9-7.1/man/hashmap.rd r-cran-bit64-4.0.5/man/hashmap.rd --- r-cran-bit64-0.9-7.1/man/hashmap.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/hashmap.rd 2020-07-31 16:06:51.000000000 +0000 @@ -76,7 +76,7 @@ \details{ \tabular{rrl}{ \bold{function} \tab \bold{see also} \tab \bold{description} \cr - \code{hashfun} \tab \code{\link[digest]{digest}} \tab export of the hash function used in \code{hashmap} \cr + \code{hashfun} \tab \code{digest} \tab export of the hash function used in \code{hashmap} \cr \code{hashmap} \tab \code{\link[=match.integer64]{match}} \tab return hashmap \cr \code{hashpos} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{x} in \code{hashmap} \cr \code{hashrev} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{hashmap} in \code{x} \cr @@ -99,7 +99,7 @@ } \keyword{ programming } \keyword{ manip } -\seealso{ \code{\link[=match.integer64]{match}} } +\seealso{ \code{\link[=match.integer64]{match}}, \code{\link{runif64}} } \examples{ x <- as.integer64(sample(c(NA, 0:9))) y <- as.integer64(sample(c(NA, 1:9), 10, TRUE)) diff -Nru r-cran-bit64-0.9-7.1/man/qtile.rd r-cran-bit64-4.0.5/man/qtile.rd --- r-cran-bit64-0.9-7.1/man/qtile.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/qtile.rd 2020-06-14 15:15:59.000000000 +0000 @@ -14,6 +14,7 @@ qtile(x, probs=seq(0, 1, 0.25), \dots) \method{qtile}{integer64}(x, probs = seq(0, 1, 0.25), names = TRUE, method = NULL, \dots) \method{quantile}{integer64}(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type=0L, \dots) + \method{median}{integer64}(x, na.rm = FALSE, \dots) \method{mean}{integer64}(x, na.rm = FALSE, \dots) \method{summary}{integer64}(object, \dots) ## mean(x, na.rm = FALSE, ...) diff -Nru r-cran-bit64-0.9-7.1/man/ramsort.integer64.rd r-cran-bit64-4.0.5/man/ramsort.integer64.rd --- r-cran-bit64-0.9-7.1/man/ramsort.integer64.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/ramsort.integer64.rd 2020-07-31 16:11:34.000000000 +0000 @@ -81,7 +81,7 @@ \item{\dots}{ further arguments, passed from generics, ignored in methods } } \details{ - see \code{\link[bit]{ramsort}} + see \code{\link{ramsort}} } \value{ These functions return the number of \code{NAs} found or assumed during sorting @@ -91,7 +91,7 @@ } \keyword{ programming } \keyword{ manip } -\seealso{ \code{\link{ramsort}} for the generic, \code{\link[ff]{ramsort.default}} for the methods provided by package \code{\link[ff]{ff}}, \code{\link{sort.integer64}} for the sort interface and \code{\link{sortcache}} for caching the work of sorting} +\seealso{ \code{\link{ramsort}} for the generic, \code{ramsort.default} for the methods provided by package \code{ff}, \code{\link{sort.integer64}} for the sort interface and \code{\link{sortcache}} for caching the work of sorting} \examples{ x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE)) x diff -Nru r-cran-bit64-0.9-7.1/man/runif64.rd r-cran-bit64-4.0.5/man/runif64.rd --- r-cran-bit64-0.9-7.1/man/runif64.rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-bit64-4.0.5/man/runif64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -0,0 +1,46 @@ +\name{runif64} +\alias{runif64} +\title{ + integer64: random numbers +} +\description{ + Create uniform random 64-bit integers within defined range +} +\usage{ + runif64(n, min = lim.integer64()[1], max = lim.integer64()[2], replace=TRUE) +} +\arguments{ + \item{n}{ length of return vector } + \item{min}{ lower inclusive bound for random numbers } + \item{max}{ upper inclusive bound for random numbers } + \item{replace}{ set to FALSE for sampleing from a finite pool, see \code{\link{sample}} } +} +\value{ + a integer64 vector +} +\details{ + For each random integer we call R's internal C interface \code{unif_rand()} twice. + Each call is mapped to 2^32 unsigned integers. The two 32-bit patterns are concatenated + to form the new integer64. This process is repeated until the result is not a \code{NA_INTEGER64}. +} +\author{ +Jens Oehlschlägel +} +\keyword{ classes } +\keyword{distribution} +\keyword{sysdata} +\seealso{ + \code{\link{runif}}, \code{\link{hashfun}} +} +\examples{ + runif64(12) + runif64(12, -16, 16) + runif64(12, 0, as.integer64(2^60)-1) # not 2^60-1 ! + var(runif(1e4)) + var(as.double(runif64(1e4, 0, 2^40))/2^40) # ~ = 1/12 = .08333 + + table(sample(16, replace=FALSE)) + table(runif64(16, 1, 16, replace=FALSE)) + table(sample(16, replace=TRUE)) + table(runif64(16, 1, 16, replace=TRUE)) +} diff -Nru r-cran-bit64-0.9-7.1/man/sortnut.rd r-cran-bit64-4.0.5/man/sortnut.rd --- r-cran-bit64-0.9-7.1/man/sortnut.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/sortnut.rd 2020-06-14 15:15:59.000000000 +0000 @@ -1,159 +1,159 @@ -\name{sortnut} -\alias{sortnut} -\alias{sortnut.integer64} -\alias{ordernut} -\alias{ordernut.integer64} -\alias{sortfin} -\alias{sortfin.integer64} -\alias{orderpos} -\alias{orderpos.integer64} -\alias{orderfin} -\alias{orderfin.integer64} -\alias{sortorderpos} -\alias{sortorderpos.integer64} -\alias{orderdup} -\alias{orderdup.integer64} -\alias{sortorderdup} -\alias{sortorderdup.integer64} -\alias{sortuni} -\alias{sortuni.integer64} -\alias{orderuni} -\alias{orderuni.integer64} -\alias{sortorderuni} -\alias{sortorderuni.integer64} -\alias{orderupo} -\alias{orderupo.integer64} -\alias{sortorderupo} -\alias{sortorderupo.integer64} -\alias{ordertie} -\alias{ordertie.integer64} -\alias{sortordertie} -\alias{sortordertie.integer64} -\alias{sorttab} -\alias{sorttab.integer64} -\alias{ordertab} -\alias{ordertab.integer64} -\alias{sortordertab} -\alias{sortordertab.integer64} -\alias{orderkey} -\alias{orderkey.integer64} -\alias{sortorderkey} -\alias{sortorderkey.integer64} -\alias{orderrnk} -\alias{orderrnk.integer64} -\alias{sortorderrnk} -\alias{sortorderrnk.integer64} -\alias{sortqtl} -\alias{sortqtl.integer64} -\alias{orderqtl} -\alias{orderqtl.integer64} -\title{ - Searching and other uses of sorting for 64bit integers -} -\description{ - This is roughly an implementation of hash functionality but based on sorting instead on a hasmap. - Since sorting is more informative than hashingwe can do some more interesting things. -} -\usage{ -sortnut(sorted, \dots) -ordernut(table, order, \dots) -sortfin(sorted, x, \dots) -orderfin(table, order, x, \dots) -orderpos(table, order, x, \dots) -sortorderpos(sorted, order, x, \dots) -orderdup(table, order, \dots) -sortorderdup(sorted, order, \dots) -sortuni(sorted, nunique, \dots) -orderuni(table, order, nunique, \dots) -sortorderuni(table, sorted, order, nunique, \dots) -orderupo(table, order, nunique, \dots) -sortorderupo(sorted, order, nunique, keep.order = FALSE, \dots) -ordertie(table, order, nties, \dots) -sortordertie(sorted, order, nties, \dots) -sorttab(sorted, nunique, \dots) -ordertab(table, order, nunique, \dots) -sortordertab(sorted, order, \dots) -orderkey(table, order, na.skip.num = 0L, \dots) -sortorderkey(sorted, order, na.skip.num = 0L, \dots) -orderrnk(table, order, na.count, \dots) -sortorderrnk(sorted, order, na.count, \dots) -\method{sortnut}{integer64}(sorted, \dots) -\method{ordernut}{integer64}(table, order, \dots) -\method{sortfin}{integer64}(sorted, x, method=NULL, \dots) -\method{orderfin}{integer64}(table, order, x, method=NULL, \dots) -\method{orderpos}{integer64}(table, order, x, nomatch=NA, method=NULL, \dots) -\method{sortorderpos}{integer64}(sorted, order, x, nomatch=NA, method=NULL, \dots) -\method{orderdup}{integer64}(table, order, method=NULL, \dots) -\method{sortorderdup}{integer64}(sorted, order, method=NULL, \dots) -\method{sortuni}{integer64}(sorted, nunique, \dots) -\method{orderuni}{integer64}(table, order, nunique, keep.order=FALSE, \dots) -\method{sortorderuni}{integer64}(table, sorted, order, nunique, \dots) -\method{orderupo}{integer64}(table, order, nunique, keep.order=FALSE, \dots) -\method{sortorderupo}{integer64}(sorted, order, nunique, keep.order = FALSE, \dots) -\method{ordertie}{integer64}(table, order, nties, \dots) -\method{sortordertie}{integer64}(sorted, order, nties, \dots) -\method{sorttab}{integer64}(sorted, nunique, \dots) -\method{ordertab}{integer64}(table, order, nunique, denormalize=FALSE, keep.order=FALSE, \dots) -\method{sortordertab}{integer64}(sorted, order, denormalize=FALSE, \dots) -\method{orderkey}{integer64}(table, order, na.skip.num = 0L, \dots) -\method{sortorderkey}{integer64}(sorted, order, na.skip.num = 0L, \dots) -\method{orderrnk}{integer64}(table, order, na.count, \dots) -\method{sortorderrnk}{integer64}(sorted, order, na.count, \dots) -\method{sortqtl}{integer64}(sorted, na.count, probs, \dots) -\method{orderqtl}{integer64}(table, order, na.count, probs, \dots) -} -\arguments{ - \item{x}{ an \code{\link{integer64}} vector } - \item{sorted}{ a sorted \code{\link{integer64}} vector } - \item{table}{ the original data with original order under the sorted vector } - \item{order}{ an \code{\link{integer}} order vector that turns 'table' into 'sorted' } - \item{nunique}{ number of unique elements, usually we get this from cache or call \code{sortnut} or \code{ordernut} } - \item{nties}{ number of tied values, usually we get this from cache or call \code{sortnut} or \code{ordernut} } - \item{denormalize}{ FALSE returns counts of unique values, TRUE returns each value with its counts } - \item{nomatch}{ the value to be returned if an element is not found in the hashmap } - \item{keep.order}{ determines order of results and speed: \code{FALSE} (the default) is faster and returns in sorted order, \code{TRUE} returns in the order of first appearance in the original data, but this requires extra work } - \item{probs}{ vector of probabilities in [0..1] for which we seek quantiles } - \item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA}, the latter needed for \code{\link{as.factor.integer64}} } - \item{na.count}{ the number of \code{NA}s, needed for this low-level function algorithm } - \item{method}{ see details } - \item{\dots}{ further arguments, passed from generics, ignored in methods } -} -\details{ -\tabular{rrrrl}{ - \bold{sortfun} \tab \bold{orderfun} \tab \bold{sortorderfun} \tab \bold{see also} \tab \bold{description} \cr - \code{sortnut} \tab \code{ordernut} \tab \tab \tab return number of tied and of unique values \cr - \code{sortfin} \tab \code{orderfin} \tab \tab \code{\link{\%in\%.integer64}} \tab return logical whether \code{x} is in \code{table} \cr - \tab \code{orderpos} \tab \code{sortorderpos} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{x} in \code{table} \cr - \tab \code{orderdup} \tab \code{sortorderdup} \tab \code{\link[=duplicated.integer64]{duplicated}} \tab return logical whether values are duplicated \cr - \code{sortuni} \tab \code{orderuni} \tab \code{sortorderuni} \tab \code{\link[=unique.integer64]{unique}} \tab return unique values (=dimensiontable) \cr - \tab \code{orderupo} \tab \code{sortorderupo} \tab \code{\link[=unique.integer64]{unique}} \tab return positions of unique values \cr - \tab \code{ordertie} \tab \code{sortordertie} \tab \tab return positions of tied values \cr - \tab \code{orderkey} \tab \code{sortorderkey} \tab \tab positions of values in vector of unique values (match in dimensiontable) \cr - \code{sorttab} \tab \code{ordertab} \tab \code{sortordertab} \tab \code{\link[=table.integer64]{table}} \tab tabulate frequency of values \cr - \tab \code{orderrnk} \tab \code{sortorderrnk} \tab \tab rank averaging ties \cr - \code{sortqtl} \tab \code{orderqtl} \tab \tab \tab return quantiles given probabilities \cr -} -The functions \code{sortfin}, \code{orderfin}, \code{orderpos} and \code{sortorderpos} each offer three algorithms for finding \code{x} in \code{table}. \cr -With \code{method=1L} each value of \code{x} is searched independently using \emph{binary search}, this is fastest for small \code{table}s. \cr -With \code{method=2L} the values of \code{x} are first sorted and then searched using \emph{doubly exponential search}, this is the best allround method. \cr -With \code{method=3L} the values of \code{x} are first sorted and then searched using simple merging, this is the fastest method if \code{table} is huge and \code{x} has similar size and distribution of values. \cr -With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr - -The functions \code{orderdup} and \code{sortorderdup} each offer two algorithms for setting the truth values in the return vector. \cr -With \code{method=1L} the return values are set directly which causes random write access on a possibly large return vector. \cr -With \code{method=2L} the return values are first set in a smaller bit-vector -- random access limited to a smaller memory region -- and finally written sequentially to the logical output vector. \cr -With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr -} -\value{ - see details -} -\author{ -Jens Oehlschlägel -} -\keyword{ programming } -\keyword{ manip } -\seealso{ \code{\link[=match.integer64]{match}} } -\examples{ - message("check the code of 'optimizer64' for examples:") - print(optimizer64) -} +\name{sortnut} +\alias{sortnut} +\alias{sortnut.integer64} +\alias{ordernut} +\alias{ordernut.integer64} +\alias{sortfin} +\alias{sortfin.integer64} +\alias{orderpos} +\alias{orderpos.integer64} +\alias{orderfin} +\alias{orderfin.integer64} +\alias{sortorderpos} +\alias{sortorderpos.integer64} +\alias{orderdup} +\alias{orderdup.integer64} +\alias{sortorderdup} +\alias{sortorderdup.integer64} +\alias{sortuni} +\alias{sortuni.integer64} +\alias{orderuni} +\alias{orderuni.integer64} +\alias{sortorderuni} +\alias{sortorderuni.integer64} +\alias{orderupo} +\alias{orderupo.integer64} +\alias{sortorderupo} +\alias{sortorderupo.integer64} +\alias{ordertie} +\alias{ordertie.integer64} +\alias{sortordertie} +\alias{sortordertie.integer64} +\alias{sorttab} +\alias{sorttab.integer64} +\alias{ordertab} +\alias{ordertab.integer64} +\alias{sortordertab} +\alias{sortordertab.integer64} +\alias{orderkey} +\alias{orderkey.integer64} +\alias{sortorderkey} +\alias{sortorderkey.integer64} +\alias{orderrnk} +\alias{orderrnk.integer64} +\alias{sortorderrnk} +\alias{sortorderrnk.integer64} +\alias{sortqtl} +\alias{sortqtl.integer64} +\alias{orderqtl} +\alias{orderqtl.integer64} +\title{ + Searching and other uses of sorting for 64bit integers +} +\description{ + This is roughly an implementation of hash functionality but based on sorting instead on a hasmap. + Since sorting is more informative than hashingwe can do some more interesting things. +} +\usage{ +sortnut(sorted, \dots) +ordernut(table, order, \dots) +sortfin(sorted, x, \dots) +orderfin(table, order, x, \dots) +orderpos(table, order, x, \dots) +sortorderpos(sorted, order, x, \dots) +orderdup(table, order, \dots) +sortorderdup(sorted, order, \dots) +sortuni(sorted, nunique, \dots) +orderuni(table, order, nunique, \dots) +sortorderuni(table, sorted, order, nunique, \dots) +orderupo(table, order, nunique, \dots) +sortorderupo(sorted, order, nunique, keep.order = FALSE, \dots) +ordertie(table, order, nties, \dots) +sortordertie(sorted, order, nties, \dots) +sorttab(sorted, nunique, \dots) +ordertab(table, order, nunique, \dots) +sortordertab(sorted, order, \dots) +orderkey(table, order, na.skip.num = 0L, \dots) +sortorderkey(sorted, order, na.skip.num = 0L, \dots) +orderrnk(table, order, na.count, \dots) +sortorderrnk(sorted, order, na.count, \dots) +\method{sortnut}{integer64}(sorted, \dots) +\method{ordernut}{integer64}(table, order, \dots) +\method{sortfin}{integer64}(sorted, x, method=NULL, \dots) +\method{orderfin}{integer64}(table, order, x, method=NULL, \dots) +\method{orderpos}{integer64}(table, order, x, nomatch=NA, method=NULL, \dots) +\method{sortorderpos}{integer64}(sorted, order, x, nomatch=NA, method=NULL, \dots) +\method{orderdup}{integer64}(table, order, method=NULL, \dots) +\method{sortorderdup}{integer64}(sorted, order, method=NULL, \dots) +\method{sortuni}{integer64}(sorted, nunique, \dots) +\method{orderuni}{integer64}(table, order, nunique, keep.order=FALSE, \dots) +\method{sortorderuni}{integer64}(table, sorted, order, nunique, \dots) +\method{orderupo}{integer64}(table, order, nunique, keep.order=FALSE, \dots) +\method{sortorderupo}{integer64}(sorted, order, nunique, keep.order = FALSE, \dots) +\method{ordertie}{integer64}(table, order, nties, \dots) +\method{sortordertie}{integer64}(sorted, order, nties, \dots) +\method{sorttab}{integer64}(sorted, nunique, \dots) +\method{ordertab}{integer64}(table, order, nunique, denormalize=FALSE, keep.order=FALSE, \dots) +\method{sortordertab}{integer64}(sorted, order, denormalize=FALSE, \dots) +\method{orderkey}{integer64}(table, order, na.skip.num = 0L, \dots) +\method{sortorderkey}{integer64}(sorted, order, na.skip.num = 0L, \dots) +\method{orderrnk}{integer64}(table, order, na.count, \dots) +\method{sortorderrnk}{integer64}(sorted, order, na.count, \dots) +\method{sortqtl}{integer64}(sorted, na.count, probs, \dots) +\method{orderqtl}{integer64}(table, order, na.count, probs, \dots) +} +\arguments{ + \item{x}{ an \code{\link{integer64}} vector } + \item{sorted}{ a sorted \code{\link{integer64}} vector } + \item{table}{ the original data with original order under the sorted vector } + \item{order}{ an \code{\link{integer}} order vector that turns 'table' into 'sorted' } + \item{nunique}{ number of unique elements, usually we get this from cache or call \code{sortnut} or \code{ordernut} } + \item{nties}{ number of tied values, usually we get this from cache or call \code{sortnut} or \code{ordernut} } + \item{denormalize}{ FALSE returns counts of unique values, TRUE returns each value with its counts } + \item{nomatch}{ the value to be returned if an element is not found in the hashmap } + \item{keep.order}{ determines order of results and speed: \code{FALSE} (the default) is faster and returns in sorted order, \code{TRUE} returns in the order of first appearance in the original data, but this requires extra work } + \item{probs}{ vector of probabilities in [0..1] for which we seek quantiles } + \item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA}, the latter needed for \code{\link{as.factor.integer64}} } + \item{na.count}{ the number of \code{NA}s, needed for this low-level function algorithm } + \item{method}{ see details } + \item{\dots}{ further arguments, passed from generics, ignored in methods } +} +\details{ +\tabular{rrrrl}{ + \bold{sortfun} \tab \bold{orderfun} \tab \bold{sortorderfun} \tab \bold{see also} \tab \bold{description} \cr + \code{sortnut} \tab \code{ordernut} \tab \tab \tab return number of tied and of unique values \cr + \code{sortfin} \tab \code{orderfin} \tab \tab \code{\link{\%in\%.integer64}} \tab return logical whether \code{x} is in \code{table} \cr + \tab \code{orderpos} \tab \code{sortorderpos} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{x} in \code{table} \cr + \tab \code{orderdup} \tab \code{sortorderdup} \tab \code{\link[=duplicated.integer64]{duplicated}} \tab return logical whether values are duplicated \cr + \code{sortuni} \tab \code{orderuni} \tab \code{sortorderuni} \tab \code{\link[=unique.integer64]{unique}} \tab return unique values (=dimensiontable) \cr + \tab \code{orderupo} \tab \code{sortorderupo} \tab \code{\link[=unique.integer64]{unique}} \tab return positions of unique values \cr + \tab \code{ordertie} \tab \code{sortordertie} \tab \tab return positions of tied values \cr + \tab \code{orderkey} \tab \code{sortorderkey} \tab \tab positions of values in vector of unique values (match in dimensiontable) \cr + \code{sorttab} \tab \code{ordertab} \tab \code{sortordertab} \tab \code{\link[=table.integer64]{table}} \tab tabulate frequency of values \cr + \tab \code{orderrnk} \tab \code{sortorderrnk} \tab \tab rank averaging ties \cr + \code{sortqtl} \tab \code{orderqtl} \tab \tab \tab return quantiles given probabilities \cr +} +The functions \code{sortfin}, \code{orderfin}, \code{orderpos} and \code{sortorderpos} each offer three algorithms for finding \code{x} in \code{table}. \cr +With \code{method=1L} each value of \code{x} is searched independently using \emph{binary search}, this is fastest for small \code{table}s. \cr +With \code{method=2L} the values of \code{x} are first sorted and then searched using \emph{doubly exponential search}, this is the best allround method. \cr +With \code{method=3L} the values of \code{x} are first sorted and then searched using simple merging, this is the fastest method if \code{table} is huge and \code{x} has similar size and distribution of values. \cr +With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr + +The functions \code{orderdup} and \code{sortorderdup} each offer two algorithms for setting the truth values in the return vector. \cr +With \code{method=1L} the return values are set directly which causes random write access on a possibly large return vector. \cr +With \code{method=2L} the return values are first set in a smaller bit-vector -- random access limited to a smaller memory region -- and finally written sequentially to the logical output vector. \cr +With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr +} +\value{ + see details +} +\author{ +Jens Oehlschlägel +} +\keyword{ programming } +\keyword{ manip } +\seealso{ \code{\link[=match.integer64]{match}} } +\examples{ + message("check the code of 'optimizer64' for examples:") + print(optimizer64) +} diff -Nru r-cran-bit64-0.9-7.1/man/sum.integer64.rd r-cran-bit64-4.0.5/man/sum.integer64.rd --- r-cran-bit64-0.9-7.1/man/sum.integer64.rd 2017-04-15 00:09:41.000000000 +0000 +++ r-cran-bit64-4.0.5/man/sum.integer64.rd 2020-06-14 15:15:59.000000000 +0000 @@ -19,7 +19,7 @@ \method{any}{integer64}(\dots, na.rm = FALSE) \method{min}{integer64}(\dots, na.rm = FALSE) \method{max}{integer64}(\dots, na.rm = FALSE) -\method{range}{integer64}(\dots, na.rm = FALSE) +\method{range}{integer64}(\dots, na.rm = FALSE, finite = FALSE) lim.integer64() \method{sum}{integer64}(\dots, na.rm = FALSE) \method{prod}{integer64}(\dots, na.rm = FALSE) @@ -27,6 +27,7 @@ \arguments{ \item{\dots}{ atomic vectors of class 'integer64'} \item{na.rm}{ logical scalar indicating whether to ignore NAs } + \item{finite}{ logical scalar indicating whether to ignore NAs (just for compatibility with \code{\link{range.default}}) } } \details{ The numerical summary methods always return \code{integer64}. diff -Nru r-cran-bit64-0.9-7.1/MD5 r-cran-bit64-4.0.5/MD5 --- r-cran-bit64-0.9-7.1/MD5 2020-07-15 04:56:13.000000000 +0000 +++ r-cran-bit64-4.0.5/MD5 2020-08-30 07:20:02.000000000 +0000 @@ -1,37 +1,38 @@ -5e52b4d34a7c0c6a0c464244e45d7a21 *DESCRIPTION -622cf5defd3be87dd47ae8c89b4a1245 *NAMESPACE -8076b58a4b8357cfc81280f3b95dd554 *NEWS -0164771b7a15581e427accde14e3cd6e *R/cache.R -0af32b8e421b56197218cca4dc4ff5c4 *R/hash64.R -4b967dded58d570879b4003cf430da6f *R/highlevel64.R -8fb255a6d08a4cfbf6cd03a5bad22089 *R/integer64.R -d5baf40933b5d09a7e73a457d807f50c *R/patch64.R -9d0bd33cd932864c60012c87a75a17f9 *R/sort64.R -1a33c131430da5516effd5a4964b17d6 *R/sortuse64.R -3f3a915ca58e2492843b8069076e3043 *R/zzz.R -a5a307c4300ed9ca28df992777ea63c2 *data/benchmark64.data.rda -f6446dee41e508e0be0c9f9f727e95c1 *data/optimizer64.data.rda +50e3629875cd183df6dd4b81488a2a38 *DESCRIPTION +ae8b7af6542978091f0acfbf00cc6238 *NAMESPACE +7a19f6569ad1182e1bd200b189526cb9 *NEWS +86c07ab4e0171baa138615b6ab3cc3bc *R/cache.R +4065f4925f6bab602a67e14ba096794f *R/hash64.R +ae3466ef9d228dd556cc9d31f330f1c6 *R/highlevel64.R +fd0cab92b00736ed7d2579021d4a17bd *R/integer64.R +0dee96469df2cf052fa934cbff210c2c *R/patch64.R +dad55b86796df208ba66a848c3798414 *R/sort64.R +17f2813188528e52d838f8a7fc8b6362 *R/sortuse64.R +bed99cb7dc63d16ba23586474bf79689 *R/zzz.R +2787a2901d07a3f824612ff7b82903e8 *data/benchmark64.data.rda +340bec5a67dd525a3ef1c0615800cb63 *data/optimizer64.data.rda f4a44e82447e3ecac68ac6d49cb18d34 *exec/make_rd.pl -23fba14720be94643fac516a872d4909 *exec/prebuild.sh -43769b6b11285e3965e8596623489833 *inst/ANNOUNCEMENT-0.8.txt -95d3e36e2e547b1f2d43a1d96ed79bf0 *inst/ANNOUNCEMENT-0.9-Details.txt -9dcd6f7db12489e423e98069ca9d780e *inst/ANNOUNCEMENT-0.9.txt -23043832de5e1e9d49916ac1e5c0d2a1 *inst/README_devel.txt -d7c39609420badb3ffdf0a4c4b11143e *man/as.character.integer64.rd +77253c3f127e634ce6b495ac8ffd16b5 *exec/prebuild.sh +43769b6b11285e3965e8596623489833 *inst/doc/ANNOUNCEMENT-0.8.txt +95d3e36e2e547b1f2d43a1d96ed79bf0 *inst/doc/ANNOUNCEMENT-0.9-Details.txt +9dcd6f7db12489e423e98069ca9d780e *inst/doc/ANNOUNCEMENT-0.9.txt +23043832de5e1e9d49916ac1e5c0d2a1 *inst/doc/README_devel.txt +f6cc5ad7ac99a491c9c14c56fb914a3b *man/all.equal.integer64.rd +c09df80fa9cd4c8041b95e0a527ed934 *man/as.character.integer64.rd 02a3d9824f356221353af96f69d2653a *man/as.data.frame.integer64.rd -55d5fb22185012beb7ef78bc8f3169e9 *man/as.integer64.character.rd +3aae76ec50b5c5446bde80fbbaada499 *man/as.integer64.character.rd f810d39205185058ed3de001054caf0b *man/benchmark64.data.rd cd9be7b466bb9c83c8491ec82ecad04e *man/benchmark64.rd -9c058c6ac7da7a6068e97fe5bc9256b4 *man/bit64-package.rd -f5f7da6ffe036a00f03f057a90161b36 *man/bit64S3.rd +62eb536a920256dca5d4b2d30081373e *man/bit64-package.rd +6158b5a3fc249aef765dd119ecd0609b *man/bit64S3.rd 410f7df4b47d5a475c9a8db7c62fb043 *man/c.integer64.rd -e093fc73cd9a14d2ffcea5d31d595bc6 *man/cache.rd +6b20ac4900f902ad298915e5312db475 *man/cache.rd f47da4eb336a52edf35b7129d6adc386 *man/cumsum.integer64.rd 701ab8ead839c1efd4f253f84ede6591 *man/duplicated.integer64.rd -a6522d206e62fb34e7bf2509ef9d3f42 *man/extract.replace.integer64.rd -dc3bc759d6eb67955de19494bcf3242e *man/format.integer64.rd +71c7d36151b59948d59d4b39b2e0bf93 *man/extract.replace.integer64.rd +e39c32a07166967c7502fede80f92a4c *man/format.integer64.rd 53f7e28cd36887ca0b202689c912610b *man/hashcache.rd -8687c8380eee020e6587992ed81b4c32 *man/hashmap.rd +f83e9e1bdbd8b67bd0a94f6289f1c231 *man/hashmap.rd 3c1ea21f97f3020a22661a4839c5c363 *man/identical.integer64.rd 6bc257ece53ef163df6c7de011b22c23 *man/is.sorted.integer64.rd 8b3d27b7cfbdafa29a6671d94db3c206 *man/keypos.rd @@ -39,28 +40,28 @@ 877cd41c55a86ed636dd4024275b3a8f *man/optimizer64.data.rd 22fa82a50370544b72561711e25ae626 *man/plusclass.rd 508d2b301e75a75b088c78593eb2d938 *man/prank.rd -6118e1f6084f9c18620fd66438360869 *man/qtile.rd -cfd14dee5aaf989665444f039266e00f *man/ramsort.integer64.rd +c56a5ad4d7e6ca932279352fd839f05e *man/qtile.rd +21fbfd0aefc17c57c1f658eaaa7bbfe8 *man/ramsort.integer64.rd e716a537cd8581671c549bf887aa9e82 *man/rank.integer64.rd c37625f78585dac182e0d43af68c7b6b *man/rep.integer64.rd +024dda7d8be1540ac5600c045f80b460 *man/runif64.rd d6ddd25776e5dd6dcd99426f0a0ba048 *man/seq.integer64.rd 57fac749382c759082d8336aa4f2f79e *man/sort.integer64.rd -f85072bf8a29df90a523049fc88aac8e *man/sortnut.rd -fbe2e721426d9a18c1e1422c143757a1 *man/sum.integer64.rd +16e3289707e86bd1971c7649c6aed6ba *man/sortnut.rd +0bd11bb8d65704841aca8cf2ea5c8850 *man/sum.integer64.rd b42d4a70236010ee891ab1b64495ac60 *man/table.integer64.rd b7c48e95a6b6ec7d56ef5cf604710e8c *man/tiepos.rd c0beaf4d0283dda9359d26e387d518e7 *man/unipos.rd 109afee392e0ceeb76d80515a045b4d9 *man/unique.integer64.rd 0407a0fa39328691137f73aa75143255 *man/xor.integer64.rd -d74975403fc135e3bee1d8d3ecd59bc9 *src/Makevars -55b18979f3a2dc90ca67adead019e20e *src/Makevars.win +5aaac424b0fed1659c279661fa7889d0 *src/Makevars 440049706594c42d0d6bc9ce42b1a71f *src/bsearch.c ab3637aa195f4f25ac50467ac24de897 *src/bsearch.h -18a11ecb49dba47ee85c6c0ce8b210b9 *src/cache.c -7aa1939c5fe2d6107f11f5677513a4b6 *src/hash64.c -d493e44121d13e4ff061d4b392d1470e *src/init.c -8a0414a7e6691d82652b7c4fd3bde6cd *src/integer64.c -df550357a5463f72df7cffff0c1adbed *src/integer64.h -1c911c8b2b18b07b0bfcdf20981720c3 *src/sort64.c +87bab576b8227c38f61b4aff33824732 *src/cache.c +5f256277aa1d94829ca6dc0cc4a4ea21 *src/hash64.c +ebf8c45e461b35275620e899f80a62e7 *src/init.c +c8debdc3b751ca7e43298530c9d89ebc *src/integer64.c +54991ef5d4d81fdfd71957a69fa83db4 *src/integer64.h +a0fb73622faa25bae1993282f135e6c1 *src/sort64.c 1fa35d7223e92dec41817543c8110fc5 *src/sort64.h -7f8ac246081ec82487de594b1ea7d88c *src/sortuse64.c +18a114ea0674838d611c38db9902c862 *src/sortuse64.c diff -Nru r-cran-bit64-0.9-7.1/NAMESPACE r-cran-bit64-4.0.5/NAMESPACE --- r-cran-bit64-0.9-7.1/NAMESPACE 2017-05-07 17:43:24.000000000 +0000 +++ r-cran-bit64-4.0.5/NAMESPACE 2020-06-14 15:15:59.000000000 +0000 @@ -1,552 +1,569 @@ -# Namespace for bit64 (currently exporting (almost) everything in order to facilitate debugging) -# S3 atomic 64 bit integers for R -# (c) 2011 Jens Oehlschägel -# Licence: GPL2 -# Provided 'as is', use at your own risk -# Created: 2011-12-11 -# Last changed: 2012-10-07 - -useDynLib(bit64, .registration = TRUE, .fixes = "C_") - -importFrom(methods, is) -importFrom(methods, as) -importFrom(utils, packageDescription) -importFrom(utils, strOptions) -importFrom(stats, quantile, median,cor) -importFrom(graphics, barplot, par, title) - -importFrom(bit, setattr) -importFrom(bit, clone) -importFrom(bit, repeat.time) - -importFrom(bit, xor) -importFrom(bit, ramsort) -importFrom(bit, shellsort) -importFrom(bit, quicksort) -importFrom(bit, mergesort) -importFrom(bit, radixsort) -importFrom(bit, keysort) -importFrom(bit, ramorder) -importFrom(bit, shellorder) -importFrom(bit, quickorder) -importFrom(bit, mergeorder) -importFrom(bit, radixorder) -importFrom(bit, keyorder) -importFrom(bit, ramsortorder) -importFrom(bit, shellsortorder) -importFrom(bit, quicksortorder) -importFrom(bit, mergesortorder) -importFrom(bit, radixsortorder) -importFrom(bit, keysortorder) - -importFrom(bit, is.sorted) -importFrom(bit, na.count) -importFrom(bit, nvalid) -importFrom(bit, nunique) -importFrom(bit, nties) - -export( - -# == this is a complete list of R functions and metadata of this package sorted by filenames, non-exported functions are commented away == - -# -- patch64.R - patch generics -- - ":" -, ":.default" -, ":.integer64" -, "is.double" -, "is.double.default" -, "is.double.integer64" -, "match" -, "match.default" -, "%in%" -, "%in%.default" -, "rank" -, "rank.default" -#, "table" -#, "table.default" -, "order" -, "order.default" - - -# -- integer64.R - basic vector handling -- - -,"binattr" -,"plusclass" -,"minusclass" - - ,"integer64" - ,"identical.integer64" - -,"is.integer64" -,"as.integer64" - -,"as.integer64.integer64" -,"as.integer64.NULL" -,"as.integer64.character" -,"as.integer64.double" -,"as.integer64.integer" -,"as.integer64.logical" -,"as.integer64.factor" -,"NA_integer64_" - -,"as.character.integer64" -,"as.double.integer64" -,"as.integer.integer64" -,"as.logical.integer64" - -,"as.bitstring" -,"as.bitstring.integer64" - -#inherited: ,"length.integer64" -,"length<-.integer64" - -,"[.integer64" -,"[[.integer64" -,"[[<-.integer64" -,"[<-.integer64" - -,"str.integer64" -,"print.integer64" -,"format.integer64" -,"is.vector.integer64" -# as.vector.integer64 removed as requested by the CRAN maintainer ,"as.vector.integer64" -,"is.na.integer64" -,"is.nan.integer64" -,"is.finite.integer64" -,"is.infinite.integer64" -,"all.integer64" -,"any.integer64" - -,"!.integer64" -,"&.integer64" -,"|.integer64" -,"xor.integer64" - -,"!=.integer64" -,"==.integer64" -,"<.integer64" -,"<=.integer64" -,">.integer64" -,">=.integer64" - -,"+.integer64" -,"-.integer64" -,"*.integer64" -,"^.integer64" -,"/.integer64" -,"%/%.integer64" -,"%%.integer64" - -,"sign.integer64" -,"abs.integer64" -,"sqrt.integer64" -,"log.integer64" -,"log2.integer64" -,"log10.integer64" -,"floor.integer64" -,"ceiling.integer64" -,"trunc.integer64" -,"round.integer64" -,"signif.integer64" -,"scale.integer64" - -,"c.integer64" -,"rep.integer64" -,"seq.integer64" -,"cbind.integer64" -,"rbind.integer64" -,"as.data.frame.integer64" - -,"min.integer64" -,"max.integer64" -,"range.integer64" -,"lim.integer64" # not a method -,"sum.integer64" -,"prod.integer64" - -,"diff.integer64" -,"cummin.integer64" -,"cummax.integer64" -,"cumsum.integer64" -,"cumprod.integer64" - - - -# -- sort64.R - sorting -- -, sort.integer64 -, order.integer64 -#, ramsort -, ramsort.integer64 -#, ramorder -, ramorder.integer64 -#, ramsortorder -, ramsortorder.integer64 -#, mergesort -, mergesort.integer64 -#, mergeorder -, mergeorder.integer64 -#, mergesortorder -, mergesortorder.integer64 -#, shellsort -, shellsort.integer64 -#, shellorder -, shellorder.integer64 -#, shellsortorder -, shellsortorder.integer64 -#, quicksort -, quicksort.integer64 -#, quickorder -, quickorder.integer64 -#, quicksortorder -, quicksortorder.integer64 -#, radixsort -, radixsort.integer64 -#, radixsortorder -, radixsortorder.integer64 -#, radixorder -, radixorder.integer64 - -# -- sortmerge64.R - searching & merging -- - -, sortnut -, sortnut.integer64 -, ordernut -, ordernut.integer64 -, sortfin -, sortfin.integer64 -, orderfin -, orderfin.integer64 -, orderpos -, orderpos.integer64 -, sortorderpos -, sortorderpos.integer64 -, sortuni -, sortuni.integer64 -, orderuni -, orderuni.integer64 -, sortorderuni -, sortorderuni.integer64 -, orderupo -, orderupo.integer64 -, sortorderupo -, sortorderupo.integer64 -, ordertie -, ordertie.integer64 -, sortordertie -, sortordertie.integer64 -, orderdup -, orderdup.integer64 -, sortorderdup -, sortorderdup.integer64 -, sorttab -, sorttab.integer64 -, ordertab -, ordertab.integer64 -, sortordertab -, sortordertab.integer64 -, orderrnk -, orderrnk.integer64 -, sortorderrnk -, sortorderrnk.integer64 -, sortqtl -, sortqtl.integer64 -, orderqtl -, orderqtl.integer64 -, orderkey -, orderkey.integer64 -, sortorderkey -, sortorderkey.integer64 - -# -- hash64.R - matching -- - -, hashfun -, hashfun.integer64 -, hashmap -, hashmap.integer64 -, hashmaptab -, hashmaptab.integer64 -, hashmapuni -, hashmapuni.integer64 -, hashmapupo -, hashmapupo.integer64 -, hashpos -, hashpos.cache_integer64 -, hashrev -, hashrev.cache_integer64 -, hashfin -, hashfin.cache_integer64 -, hashrin -, hashrin.cache_integer64 -, hashdup -, hashdup.cache_integer64 -, hashuni -, hashuni.cache_integer64 -, hashupo -, hashupo.cache_integer64 -, hashtab -, hashtab.cache_integer64 - -# -- cache.R - matching -- - -, still.identical -, newcache -, jamcache -, cache -, setcache -, getcache -, remcache -, print.cache -, hashcache -, sortcache -, ordercache -, sortordercache -, na.count.integer64 -, nvalid.integer64 -, nunique.integer64 -, nties.integer64 -, is.sorted.integer64 - - -# -- highlevel64.R - matching -- - -, benchmark64 -, optimizer64 -, match.integer64 -, "%in%.integer64" -, unique.integer64 -, unipos -, unipos.integer64 -, tiepos -, tiepos.integer64 -, keypos -, keypos.integer64 -, duplicated.integer64 -, table.integer64 -, rank.integer64 -, prank -, prank.integer64 -, qtile -, qtile.integer64 -, quantile.integer64 -, median.integer64 -, mean.integer64 -, summary.integer64 - -# -- zzz.R -- - -#,.Last.lib -) - - -# -- patch64.R - patch generics -- - -S3method(":", default) -S3method(":", integer64) -S3method("is.double", default) -S3method("is.double", integer64) -S3method("match", default) -S3method("%in%", default) -S3method("rank", default) -#S3method("table", default) -S3method("order", default) - - -# -- integer64.R - basic vector handling -- - -S3method("identical", integer64) - -S3method("is", integer64) -S3method("as", integer64) - -S3method("as.integer64", integer64) -S3method("as.integer64", NULL) -S3method("as.integer64", character) -S3method("as.integer64", double) -S3method("as.integer64", integer) -S3method("as.integer64", logical) -S3method("as.integer64", factor) - -S3method("as.character", integer64) -S3method("as.double", integer64) -S3method("as.integer", integer64) -S3method("as.logical", integer64) - -S3method("as", bitstring) -S3method("as.bitstring", integer64) - -#inherited: S3method("length", integer64) -S3method("length<-", integer64) - -S3method("[", integer64) -S3method("[[", integer64) -S3method("[[<-", integer64) -S3method("[<-", integer64) - -S3method("str", integer64) -S3method("print", integer64) -S3method("format", integer64) -S3method("is.vector", integer64) -# as.vector.integer64 removed as requested by the CRAN maintainer S3method("as.vector", integer64) -S3method("is.na", integer64) -S3method("is.nan", integer64) -S3method("is.finite", integer64) -S3method("is.infinite", integer64) -S3method("all", integer64) -S3method("any", integer64) - -S3method("!", integer64) -S3method("&", integer64) -S3method("|", integer64) -S3method("xor", integer64) - -S3method("!=", integer64) -S3method("==", integer64) -S3method("<", integer64) -S3method("<=", integer64) -S3method(">", integer64) -S3method(">=", integer64) - -S3method("+", integer64) -S3method("-", integer64) -S3method("*", integer64) -S3method("^", integer64) -S3method("/", integer64) -S3method("%/%", integer64) -S3method("%%", integer64) - -S3method("sign", integer64) -S3method("abs", integer64) -S3method("sqrt", integer64) -S3method("log", integer64) -S3method("log2", integer64) -S3method("log10", integer64) -S3method("floor", integer64) -S3method("ceiling", integer64) -S3method("trunc", integer64) -S3method("round", integer64) -S3method("signif", integer64) -S3method("scale", integer64) - -S3method("c", integer64) -S3method("rep", integer64) -S3method("seq", integer64) -#S3method(":", default) -#S3method(":", integer64) -S3method("cbind", integer64) -S3method("rbind", integer64) -S3method("as.data.frame", integer64) - -S3method("min", integer64) -S3method("max", integer64) -S3method("range", integer64) -S3method("sum", integer64) -S3method("prod", integer64) - -S3method("diff", integer64) -S3method("cummin", integer64) -S3method("cummax", integer64) -S3method("cumsum", integer64) -S3method("cumprod", integer64) - - -# -- sort64.R - sorting -- - -S3method("sort", integer64) -S3method("order", integer64) -S3method("ramsort", integer64) -S3method("ramorder", integer64) -S3method("ramsortorder", integer64) -S3method("shellsort", integer64) -S3method("shellorder", integer64) -S3method("shellsortorder", integer64) -S3method("mergesort", integer64) -S3method("mergeorder", integer64) -S3method("mergesortorder", integer64) -S3method("quicksort", integer64) -S3method("quickorder", integer64) -S3method("quicksortorder", integer64) -S3method("radixsort", integer64) -S3method("radixsortorder", integer64) -S3method("radixorder", integer64) - - -# -- sortmerge64.R - searching & merging -- -S3method("sortnut", integer64) -S3method("ordernut", integer64) - -S3method("sortfin", integer64) -S3method("orderfin", integer64) - -S3method("orderpos", integer64) -S3method("sortorderpos", integer64) - -S3method("sortuni", integer64) -S3method("orderuni", integer64) -S3method("sortorderuni", integer64) - -S3method("orderupo", integer64) -S3method("sortorderupo", integer64) - -S3method("ordertie", integer64) -S3method("sortordertie", integer64) - -S3method("orderdup", integer64) -S3method("sortorderdup", integer64) - -S3method("sorttab", integer64) -S3method("ordertab", integer64) -S3method("sortordertab", integer64) - -S3method("orderkey", integer64) -S3method("sortorderkey", integer64) - -S3method("orderrnk", integer64) -S3method("sortorderrnk", integer64) - -S3method("sortqtl", integer64) -S3method("orderqtl", integer64) - - -# -- hash64.R - matching -- - -S3method("hashfun", integer64) -S3method("hashmap", integer64) -S3method("hashmaptab", integer64) -S3method("hashmapuni", integer64) -S3method("hashmapupo", integer64) -S3method("hashpos", cache_integer64) -S3method("hashrev", cache_integer64) -S3method("hashfin", cache_integer64) -S3method("hashrin", cache_integer64) -S3method("hashdup", cache_integer64) -S3method("hashuni", cache_integer64) -S3method("hashupo", cache_integer64) -S3method("hashtab", cache_integer64) - -# -- cache.R - matching -- - -S3method("print", cache) -S3method("na.count", integer64) -S3method("nvalid", integer64) -S3method("nunique", integer64) -S3method("nties", integer64) -S3method("is.sorted", integer64) - -# -- highlevel64.R - matching -- - -S3method("match", integer64) -S3method("%in%", integer64) -S3method("unique", integer64) -S3method("unipos", integer64) -S3method("tiepos", integer64) -S3method("keypos", integer64) -S3method("duplicated", integer64) -#S3method("table", integer64) -S3method("rank", integer64) -S3method("prank", integer64) -S3method("qtile", integer64) -S3method("quantile", integer64) -S3method("median", integer64) -S3method("mean", integer64) -S3method("summary", integer64) - +# Namespace for bit64 (currently exporting (almost) everything in order to facilitate debugging) +# S3 atomic 64 bit integers for R +# (c) 2011 Jens Oehlschägel +# Licence: GPL2 +# Provided 'as is', use at your own risk +# Created: 2011-12-11 +# Last changed: 2012-10-07 + +useDynLib(bit64, .registration = TRUE, .fixes = "C_") + +importFrom(methods, is) +importFrom(methods, as) +importFrom(utils, packageDescription) +importFrom(utils, strOptions) +importFrom(stats, quantile, median,cor) +importFrom(graphics, barplot, par, title) + +importFrom(bit, setattr) +importFrom(bit, clone) +importFrom(bit, repeat.time) + +importFrom(bit, xor) +importFrom(bit, ramsort) +importFrom(bit, shellsort) +importFrom(bit, quicksort) +importFrom(bit, mergesort) +importFrom(bit, radixsort) +importFrom(bit, keysort) +importFrom(bit, ramorder) +importFrom(bit, shellorder) +importFrom(bit, quickorder) +importFrom(bit, mergeorder) +importFrom(bit, radixorder) +importFrom(bit, keyorder) +importFrom(bit, ramsortorder) +importFrom(bit, shellsortorder) +importFrom(bit, quicksortorder) +importFrom(bit, mergesortorder) +importFrom(bit, radixsortorder) +importFrom(bit, keysortorder) + +importFrom(bit, is.sorted) +importFrom(bit, na.count) +importFrom(bit, nvalid) +importFrom(bit, nunique) +importFrom(bit, nties) + +export( + +# == this is a complete list of R functions and metadata of this package sorted by filenames, non-exported functions are commented away == + +# -- patch64.R - patch generics -- + ":" +, ":.default" +, ":.integer64" +, "is.double" +, "is.double.default" +, "is.double.integer64" +, "match" +, "match.default" +, "%in%" +, "%in%.default" +, "rank" +, "rank.default" +#, "table" +#, "table.default" +, "order" +, "order.default" + + +# -- integer64.R - basic vector handling -- + +,"binattr" +,"plusclass" +,"minusclass" + + ,"integer64" + ,"all.equal.integer64" + ,"identical.integer64" + +,"is.integer64" +,"as.integer64" + +,"as.integer64.integer64" +,"as.integer64.NULL" +,"as.integer64.character" +,"as.integer64.double" +,"as.integer64.integer" +,"as.integer64.logical" +,"as.integer64.factor" +,"NA_integer64_" + +,"as.character.integer64" +,"as.double.integer64" +,"as.integer.integer64" +,"as.logical.integer64" + +,"as.bitstring" +,"as.bitstring.integer64" +,"as.integer64.bitstring" +,"print.bitstring" + +#inherited: ,"length.integer64" +,"length<-.integer64" + +,"[.integer64" +,"[[.integer64" +,"[[<-.integer64" +,"[<-.integer64" + +,"str.integer64" +,"print.integer64" +,"format.integer64" +,"is.vector.integer64" +# as.vector.integer64 removed as requested by the CRAN maintainer ,"as.vector.integer64" +,"is.na.integer64" +,"is.nan.integer64" +,"is.finite.integer64" +,"is.infinite.integer64" +,"all.integer64" +,"any.integer64" + +,"!.integer64" +,"&.integer64" +,"|.integer64" +,"xor.integer64" + +,"!=.integer64" +,"==.integer64" +,"<.integer64" +,"<=.integer64" +,">.integer64" +,">=.integer64" + +,"+.integer64" +,"-.integer64" +,"*.integer64" +,"^.integer64" +,"/.integer64" +,"%/%.integer64" +,"%%.integer64" + +,"sign.integer64" +,"abs.integer64" +,"sqrt.integer64" +,"log.integer64" +,"log2.integer64" +,"log10.integer64" +,"floor.integer64" +,"ceiling.integer64" +,"trunc.integer64" +,"round.integer64" +,"signif.integer64" +,"scale.integer64" + +,"c.integer64" +,"rep.integer64" +,"seq.integer64" +,"cbind.integer64" +,"rbind.integer64" +,"as.data.frame.integer64" + +,"min.integer64" +,"max.integer64" +,"range.integer64" +,"lim.integer64" # not a method +,"sum.integer64" +,"prod.integer64" + +,"diff.integer64" +,"cummin.integer64" +,"cummax.integer64" +,"cumsum.integer64" +,"cumprod.integer64" + + + +# -- sort64.R - sorting -- +, sort.integer64 +, order.integer64 +#, ramsort +, ramsort.integer64 +#, ramorder +, ramorder.integer64 +#, ramsortorder +, ramsortorder.integer64 +#, mergesort +, mergesort.integer64 +#, mergeorder +, mergeorder.integer64 +#, mergesortorder +, mergesortorder.integer64 +#, shellsort +, shellsort.integer64 +#, shellorder +, shellorder.integer64 +#, shellsortorder +, shellsortorder.integer64 +#, quicksort +, quicksort.integer64 +#, quickorder +, quickorder.integer64 +#, quicksortorder +, quicksortorder.integer64 +#, radixsort +, radixsort.integer64 +#, radixsortorder +, radixsortorder.integer64 +#, radixorder +, radixorder.integer64 + +#, radisort +#, radisort.integer64 +#, onionsort +#, onionsort.integer64 + + +# -- sortmerge64.R - searching & merging -- + +, sortnut +, sortnut.integer64 +, ordernut +, ordernut.integer64 +, sortfin +, sortfin.integer64 +, orderfin +, orderfin.integer64 +, orderpos +, orderpos.integer64 +, sortorderpos +, sortorderpos.integer64 +, sortuni +, sortuni.integer64 +, orderuni +, orderuni.integer64 +, sortorderuni +, sortorderuni.integer64 +, orderupo +, orderupo.integer64 +, sortorderupo +, sortorderupo.integer64 +, ordertie +, ordertie.integer64 +, sortordertie +, sortordertie.integer64 +, orderdup +, orderdup.integer64 +, sortorderdup +, sortorderdup.integer64 +, sorttab +, sorttab.integer64 +, ordertab +, ordertab.integer64 +, sortordertab +, sortordertab.integer64 +, orderrnk +, orderrnk.integer64 +, sortorderrnk +, sortorderrnk.integer64 +, sortqtl +, sortqtl.integer64 +, orderqtl +, orderqtl.integer64 +, orderkey +, orderkey.integer64 +, sortorderkey +, sortorderkey.integer64 + +# -- hash64.R - matching -- + +, hashfun +, hashfun.integer64 +, hashmap +, hashmap.integer64 +, hashmaptab +, hashmaptab.integer64 +, hashmapuni +, hashmapuni.integer64 +, hashmapupo +, hashmapupo.integer64 +, hashpos +, hashpos.cache_integer64 +, hashrev +, hashrev.cache_integer64 +, hashfin +, hashfin.cache_integer64 +, hashrin +, hashrin.cache_integer64 +, hashdup +, hashdup.cache_integer64 +, hashuni +, hashuni.cache_integer64 +, hashupo +, hashupo.cache_integer64 +, hashtab +, hashtab.cache_integer64 + +, runif64 + +# -- cache.R - matching -- + +#, still.identical +, newcache +, jamcache +, cache +, setcache +, getcache +, remcache +, print.cache +, hashcache +, sortcache +, ordercache +, sortordercache +, na.count.integer64 +, nvalid.integer64 +, nunique.integer64 +, nties.integer64 +, is.sorted.integer64 + + +# -- highlevel64.R - matching -- + +, benchmark64 +, optimizer64 +, match.integer64 +, "%in%.integer64" +, unique.integer64 +, unipos +, unipos.integer64 +, tiepos +, tiepos.integer64 +, keypos +, keypos.integer64 +, duplicated.integer64 +, table.integer64 +, rank.integer64 +, prank +, prank.integer64 +, qtile +, qtile.integer64 +, quantile.integer64 +, median.integer64 +, mean.integer64 +, summary.integer64 + +# -- zzz.R -- + +#,.Last.lib +) + + +# -- patch64.R - patch generics -- + +S3method(":", default) +S3method(":", integer64) +S3method("is.double", default) +S3method("is.double", integer64) +S3method("match", default) +S3method("%in%", default) +S3method("rank", default) +#S3method("table", default) +S3method("order", default) + + +# -- integer64.R - basic vector handling -- + +S3method("all.equal", integer64) +S3method("identical", integer64) + +S3method("is", integer64) +S3method("as", integer64) + +S3method("as.integer64", integer64) +S3method("as.integer64", NULL) +S3method("as.integer64", character) +S3method("as.integer64", bitstring) +S3method("as.integer64", double) +S3method("as.integer64", integer) +S3method("as.integer64", logical) +S3method("as.integer64", factor) + +S3method("as.character", integer64) +S3method("as.double", integer64) +S3method("as.integer", integer64) +S3method("as.logical", integer64) + +S3method("as", bitstring) +S3method("as.bitstring", integer64) +S3method("print", bitstring) + +#inherited: S3method("length", integer64) +S3method("length<-", integer64) + +S3method("[", integer64) +S3method("[[", integer64) +S3method("[[<-", integer64) +S3method("[<-", integer64) + +S3method("str", integer64) +S3method("print", integer64) +S3method("format", integer64) +S3method("is.vector", integer64) +# as.vector.integer64 removed as requested by the CRAN maintainer S3method("as.vector", integer64) +S3method("is.na", integer64) +S3method("is.nan", integer64) +S3method("is.finite", integer64) +S3method("is.infinite", integer64) +S3method("all", integer64) +S3method("any", integer64) + +S3method("!", integer64) +S3method("&", integer64) +S3method("|", integer64) +S3method("xor", integer64) + +S3method("!=", integer64) +S3method("==", integer64) +S3method("<", integer64) +S3method("<=", integer64) +S3method(">", integer64) +S3method(">=", integer64) + +S3method("+", integer64) +S3method("-", integer64) +S3method("*", integer64) +S3method("^", integer64) +S3method("/", integer64) +S3method("%/%", integer64) +S3method("%%", integer64) + +S3method("sign", integer64) +S3method("abs", integer64) +S3method("sqrt", integer64) +S3method("log", integer64) +S3method("log2", integer64) +S3method("log10", integer64) +S3method("floor", integer64) +S3method("ceiling", integer64) +S3method("trunc", integer64) +S3method("round", integer64) +S3method("signif", integer64) +S3method("scale", integer64) + +S3method("c", integer64) +S3method("rep", integer64) +S3method("seq", integer64) +#S3method(":", default) +#S3method(":", integer64) +S3method("cbind", integer64) +S3method("rbind", integer64) +S3method("as.data.frame", integer64) + +S3method("min", integer64) +S3method("max", integer64) +S3method("range", integer64) +S3method("sum", integer64) +S3method("prod", integer64) + +S3method("diff", integer64) +S3method("cummin", integer64) +S3method("cummax", integer64) +S3method("cumsum", integer64) +S3method("cumprod", integer64) + + +# -- sort64.R - sorting -- + +S3method("sort", integer64) +S3method("order", integer64) +S3method("ramsort", integer64) +S3method("ramorder", integer64) +S3method("ramsortorder", integer64) +S3method("shellsort", integer64) +S3method("shellorder", integer64) +S3method("shellsortorder", integer64) +S3method("mergesort", integer64) +S3method("mergeorder", integer64) +S3method("mergesortorder", integer64) +S3method("quicksort", integer64) +S3method("quickorder", integer64) +S3method("quicksortorder", integer64) +S3method("radixsort", integer64) +S3method("radixsortorder", integer64) +S3method("radixorder", integer64) + +#S3method("radisort", integer64) +#S3method("onionsort", integer64) + + +# -- sortmerge64.R - searching & merging -- +S3method("sortnut", integer64) +S3method("ordernut", integer64) + +S3method("sortfin", integer64) +S3method("orderfin", integer64) + +S3method("orderpos", integer64) +S3method("sortorderpos", integer64) + +S3method("sortuni", integer64) +S3method("orderuni", integer64) +S3method("sortorderuni", integer64) + +S3method("orderupo", integer64) +S3method("sortorderupo", integer64) + +S3method("ordertie", integer64) +S3method("sortordertie", integer64) + +S3method("orderdup", integer64) +S3method("sortorderdup", integer64) + +S3method("sorttab", integer64) +S3method("ordertab", integer64) +S3method("sortordertab", integer64) + +S3method("orderkey", integer64) +S3method("sortorderkey", integer64) + +S3method("orderrnk", integer64) +S3method("sortorderrnk", integer64) + +S3method("sortqtl", integer64) +S3method("orderqtl", integer64) + + +# -- hash64.R - matching -- + +S3method("hashfun", integer64) +S3method("hashmap", integer64) +S3method("hashmaptab", integer64) +S3method("hashmapuni", integer64) +S3method("hashmapupo", integer64) +S3method("hashpos", cache_integer64) +S3method("hashrev", cache_integer64) +S3method("hashfin", cache_integer64) +S3method("hashrin", cache_integer64) +S3method("hashdup", cache_integer64) +S3method("hashuni", cache_integer64) +S3method("hashupo", cache_integer64) +S3method("hashtab", cache_integer64) + +# -- cache.R - matching -- + +S3method("print", cache) +S3method("na.count", integer64) +S3method("nvalid", integer64) +S3method("nunique", integer64) +S3method("nties", integer64) +S3method("is.sorted", integer64) + +# -- highlevel64.R - matching -- + +S3method("match", integer64) +S3method("%in%", integer64) +S3method("unique", integer64) +S3method("unipos", integer64) +S3method("tiepos", integer64) +S3method("keypos", integer64) +S3method("duplicated", integer64) +#S3method("table", integer64) +S3method("rank", integer64) +S3method("prank", integer64) +S3method("qtile", integer64) +S3method("quantile", integer64) +S3method("median", integer64) +S3method("mean", integer64) +S3method("summary", integer64) + diff -Nru r-cran-bit64-0.9-7.1/NEWS r-cran-bit64-4.0.5/NEWS --- r-cran-bit64-0.9-7.1/NEWS 2017-05-07 19:06:58.000000000 +0000 +++ r-cran-bit64-4.0.5/NEWS 2020-08-29 10:54:56.000000000 +0000 @@ -1,3 +1,119 @@ + CHANGES IN bit64 VERSION 4.0.5 + +BUG FIXES + + o PKG_LIBS=-lm added to Makevars + (fixes https://bugzilla.redhat.com/show_bug.cgi?id=1763127 + thanks to Elliott Sales de Andrade) + + + + CHANGES IN bit64 VERSION 4.0.4 + +BUG FIXES + + o runif64() no longer long long overflows + for the maximum integer64 range + o UBSAN false alarms removed with + __attribute__((no_sanitize("signed-integer-overflow"))) + o added temporary flags to Makefile + for UBSAN checks + + + + CHANGES IN bit64 VERSION 4.0.3 + +BUG FIXES + + o added Makefile with temporary -flto + and removed LTO error regarding runif_integer64 + + + + CHANGES IN bit64 VERSION 4.0.2 + +BUG FIXES + + o now DESCRIPTION URL points to github + + + + CHANGES IN bit64 VERSION 4.0.1 + +BUG FIXES + + o removed pragma because no longer needed with recent compilers + o removed a clang warning + + + + CHANGES IN bit64 VERSION 4.0.0 + + +NEW FEATURES + + o new method all.equal.integer64 + (contributed by Leonardo Silvestri) + + +USER VISIBLE CHANGES + + o license has been extendend from GPL-2 to GPL-2 | GPL-3 + o still.identical is now exported from package bit + + +BUG FIXES + + o removed unused SEXP ret_ from r_ram_integer64_sortnut and + r_ram_integer64_ordernut (LTO problems reported by Brian Ripley) + o min, max and range now give correct results for multiple arguments + (reported by Colin Umanski) + o r_ram_integer64_ordertab_asc and r_ram_integer64_sortordertab_asc + now properly PROTECT their shortened return vector before R_Busy(0) + (Thanks to Tomas Kalibera) + o operations on zero length integer64 now return + zero length integer64 instead of throwing an error + (reported by Xianying Tan) + o match.integer64 (and %in%) now coerce the second argument to integer64 + instead of throwing an error (reported by Xianying Tan) + o zero-length integer64() no longer prints as `character(0)` + (reported by Xianying Tan) + + + + CHANGES IN bit64 VERSION 0.9-8 + + +NEW FEATURES + + o New function runif64 which can sample from finite + and infinite populations (wish of Dan Reznik) + + o New methods as.integer64.bitstring + and print.bitstring (wish of Dan Reznik) + + +USER VISIBLE CHANGES + + o [.integer64 now returns NA where the subscripts require this + (contributed by Leonardo Silvestri) + o binary operators now handle attributes more like R + (new binattr() code contributed by Leonardo Silvestri) + o as.bitstring.integer64 now returns its string vector + with class 'bitstring' + o round.integer64 with a negative digits argument now rounds + like round(integer) would do (wish of Ian Lyttle) + o range.integer64 now has an argument finite=FALSE for compatibility + with range.default (wish of Sergio Oller) + + +BUG FIXES + + o calculating hashbits in hashfun, hashmap, hashmaptab and hashmapuni + now gives 0 instead of stopping (bug reported by Jakob Schelbert) + + + CHANGES IN bit64 VERSION 0.9-7 BUG FIXES @@ -14,7 +130,7 @@ and no longer the underlying double (wish of Matt Dowle) o New integer64 methods is.nan, is.finite, is.infinite - (wish of Florent Angly + (wish of Florent Angly) USER VISIBLE CHANGES diff -Nru r-cran-bit64-0.9-7.1/R/cache.R r-cran-bit64-4.0.5/R/cache.R --- r-cran-bit64-0.9-7.1/R/cache.R 2017-05-07 18:05:51.000000000 +0000 +++ r-cran-bit64-4.0.5/R/cache.R 2020-06-14 15:15:59.000000000 +0000 @@ -16,7 +16,6 @@ #! \alias{getcache} #! \alias{remcache} #! \alias{print.cache} -#! \alias{still.identical} #! \title{ #! Atomic Caching #! } @@ -31,15 +30,11 @@ #! getcache(x, which) #! remcache(x) #! \method{print}{cache}(x, all.names = FALSE, pattern, \dots) -#! still.identical(x, y) #! } #! \arguments{ #! \item{x}{ #! an integer64 vector (or a cache object in case of \code{print.cache}) #! } -#! \item{y}{ -#! an integer64 vector -#! } #! \item{which}{ #! A character naming the object to be retrieved from the cache or to be stored in the cache #! } @@ -60,7 +55,6 @@ #! A \code{cache} is an \code{link{environment}} attached to an atomic object with the \code{link{attrib}} name 'cache'. #! It contains at least a reference to the atomic object that carries the cache. #! This is used when accessing the cache to detect whether the object carrying the cache has been modified meanwhile. -#! Function \code{still.identical(x,y)} checks whether the objects \code{x} and \code{y} \cr #! Function \code{newcache(x)} creates a new cache referencing \code{x} \cr #! Function \code{jamcache(x)} forces \code{x} to have a cache \cr #! Function \code{cache(x)} returns the cache attached to \code{x} if it is not found to be outdated \cr @@ -75,6 +69,7 @@ #! Jens Oehlschlägel #! } #! \seealso{ +#! \code{\link{still.identical}} for testing whether to symbols point to the same RAM. \cr #! Functions that get and set small cache-content automatically when a cache is present: \code{\link{na.count}}, \code{\link{nvalid}}, \code{\link{is.sorted}}, \code{\link{nunique}} and \code{\link{nties}} \cr #! Setting big caches with a relevant memory footprint requires a conscious decision of the user: \code{\link{hashcache}}, \code{\link{sortcache}}, \code{\link{ordercache}} and \code{\link{sortordercache}} \cr #! Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{as.factor.integer64}}, \code{\link{as.ordered.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr @@ -101,9 +96,9 @@ #! } #! \keyword{ environment } -still.identical <- function(x, y){ - .Call(C_r_ram_truly_identical, x = x, y = y, PACKAGE = "bit64") -} +#still.identical <- function(x, y){ +# .Call(C_r_ram_truly_identical, x = x, y = y, PACKAGE = "bit64") +#} newcache <- function(x){ env <- new.env() @@ -121,7 +116,7 @@ cache <- newcache(x) setattr(x, "cache", cache) }else - if (!still.identical(x, get("x", envir=cache, inherits=FALSE))){ + if (!bit::still.identical(x, get("x", envir=cache, inherits=FALSE))){ cache <- newcache(x) setattr(x, "cache", cache) warning("replaced outdated cache with empty cache") @@ -131,7 +126,7 @@ cache <- function(x){ cache <- attr(x, "cache") - if (is.null(cache) || still.identical(x, get("x", envir=cache, inherits=FALSE))) + if (is.null(cache) || bit::still.identical(x, get("x", envir=cache, inherits=FALSE))) cache else{ remcache(x) @@ -150,7 +145,7 @@ cache <- attr(x, "cache") if (is.null(cache)) return(NULL) - if (still.identical(x, get("x", envir=cache, inherits=FALSE))){ + if (bit::still.identical(x, get("x", envir=cache, inherits=FALSE))){ if (exists(which, envir=cache, inherits=FALSE)) get(which, envir=cache, inherits=FALSE) else diff -Nru r-cran-bit64-0.9-7.1/R/hash64.R r-cran-bit64-4.0.5/R/hash64.R --- r-cran-bit64-0.9-7.1/R/hash64.R 2017-05-07 18:05:52.000000000 +0000 +++ r-cran-bit64-4.0.5/R/hash64.R 2020-08-07 11:56:50.000000000 +0000 @@ -87,7 +87,7 @@ #! \details{ #! \tabular{rrl}{ #! \bold{function} \tab \bold{see also} \tab \bold{description} \cr -#! \code{hashfun} \tab \code{\link[digest]{digest}} \tab export of the hash function used in \code{hashmap} \cr +#! \code{hashfun} \tab \code{digest} \tab export of the hash function used in \code{hashmap} \cr #! \code{hashmap} \tab \code{\link[=match.integer64]{match}} \tab return hashmap \cr #! \code{hashpos} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{x} in \code{hashmap} \cr #! \code{hashrev} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{hashmap} in \code{x} \cr @@ -110,7 +110,7 @@ #! } #! \keyword{ programming } #! \keyword{ manip } -#! \seealso{ \code{\link[=match.integer64]{match}} } +#! \seealso{ \code{\link[=match.integer64]{match}}, \code{\link{runif64}} } #! \examples{ #! x <- as.integer64(sample(c(NA, 0:9))) #! y <- as.integer64(sample(c(NA, 1:9), 10, TRUE)) @@ -175,14 +175,16 @@ n <- length(x) if (is.null(hashbits)){ minlen <- ceiling(n*minfac) - hashbits <- as.integer(ceiling(log2(minlen))) + if (minlen > 0L) + hashbits <- as.integer(ceiling(log2(minlen))) + else + hashbits <- 0L }else hashbits <- as.integer(hashbits) - ret <- integer(n) - .Call(C_hashfun_integer64, x, hashbits, ret, PACKAGE = "bit64") - ret + .Call(C_hashfun_integer64, x, hashbits, integer(n), PACKAGE = "bit64") } + hashmap <- function(x, ...)UseMethod("hashmap") hashmap.integer64 <- function(x, nunique=NULL, minfac=1.41, hashbits=NULL, cache=NULL, ...){ if (is.null(nunique)){ @@ -192,18 +194,22 @@ nunique <- as.integer(nunique) n <- nunique } - if (is.null(hashbits)) - hashbits <- as.integer(ceiling(log2(n*minfac))) - else + if (is.null(hashbits)){ + minlen <- ceiling(n*minfac) + if (minlen > 0L) + hashbits <- as.integer(ceiling(log2(minlen))) + else + hashbits <- 0L + }else hashbits <- as.integer(hashbits) nhash <- as.integer(2^hashbits) hashmap <- integer(nhash) .Call(C_hashmap_integer64, x, hashbits, hashmap, nunique, PACKAGE = "bit64") if (is.null(cache)) - cache <- newcache(x) + cache <- newcache(x) else - if (!still.identical(x, get("x", envir=cache, inherits=FALSE))) + if (!bit::still.identical(x, get("x", envir=cache, inherits=FALSE))) stop("vector 'x' dissociated from cache") assign("hashmap", hashmap, envir=cache) assign("hashbits", hashbits, envir=cache) @@ -212,14 +218,14 @@ cache } + + hashpos <- function(cache, ...)UseMethod("hashpos") hashpos.cache_integer64 <- function(cache, x, nomatch = NA_integer_, ...){ hashbits <- get("hashbits", envir=cache, inherits=FALSE) hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) - ret <- integer(length(x)) - .Call(C_hashpos_integer64, as.integer64(x), hashdat, hashbits, hashmap, as.integer(nomatch), ret, PACKAGE = "bit64") - ret + .Call(C_hashpos_integer64, as.integer64(x), hashdat, hashbits, hashmap, as.integer(nomatch), integer(length(x)), PACKAGE = "bit64") } hashrev <- function(cache, ...)UseMethod("hashrev") @@ -228,9 +234,7 @@ hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) nunique <- get("nunique", envir=cache, inherits=FALSE) - ret <- integer(length(hashdat)) - .Call(C_hashrev_integer64, as.integer64(x), hashdat, hashbits, hashmap, nunique, as.integer(nomatch), ret, PACKAGE = "bit64") - ret + .Call(C_hashrev_integer64, as.integer64(x), hashdat, hashbits, hashmap, nunique, as.integer(nomatch), integer(length(hashdat)), PACKAGE = "bit64") } hashfin <- function(cache, ...)UseMethod("hashfin") @@ -238,9 +242,7 @@ hashbits <- get("hashbits", envir=cache, inherits=FALSE) hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) - ret <- logical(length(x)) - .Call(C_hashfin_integer64, as.integer64(x), hashdat, hashbits, hashmap, ret, PACKAGE = "bit64") - ret + .Call(C_hashfin_integer64, as.integer64(x), hashdat, hashbits, hashmap, logical(length(x)), PACKAGE = "bit64") } hashrin <- function(cache, ...)UseMethod("hashrin") @@ -248,9 +250,7 @@ hashbits <- get("hashbits", envir=cache, inherits=FALSE) hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) - ret <- logical(length(hashdat)) - .Call(C_hashrin_integer64, as.integer64(x), hashdat, hashbits, hashmap, nunique, ret, PACKAGE = "bit64") - ret + .Call(C_hashrin_integer64, as.integer64(x), hashdat, hashbits, hashmap, nunique, logical(length(hashdat)), PACKAGE = "bit64") } @@ -260,9 +260,7 @@ hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) nunique <- get("nunique", envir=cache, inherits=FALSE) - ret <- logical(length(hashdat)) - .Call(C_hashdup_integer64, hashdat, hashbits, hashmap, nunique, ret, PACKAGE = "bit64") - ret + .Call(C_hashdup_integer64, hashdat, hashbits, hashmap, nunique, logical(length(hashdat)), PACKAGE = "bit64") } hashuni <- function(cache, ...)UseMethod("hashuni") @@ -271,8 +269,7 @@ hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) nunique <- get("nunique", envir=cache, inherits=FALSE) - ret <- double(nunique) - .Call(C_hashuni_integer64, hashdat, hashbits, hashmap, as.logical(keep.order), ret, PACKAGE = "bit64") + ret <- .Call(C_hashuni_integer64, hashdat, hashbits, hashmap, as.logical(keep.order), double(nunique), PACKAGE = "bit64") oldClass(ret) <- "integer64" ret } @@ -283,9 +280,7 @@ hashmap <- get("hashmap", envir=cache, inherits=FALSE) hashdat <- get("x", envir=cache, inherits=FALSE) nunique <- get("nunique", envir=cache, inherits=FALSE) - ret <- integer(nunique) - .Call(C_hashupo_integer64, hashdat, hashbits, hashmap, as.logical(keep.order), ret, PACKAGE = "bit64") - ret + .Call(C_hashupo_integer64, hashdat, hashbits, hashmap, as.logical(keep.order), integer(nunique), PACKAGE = "bit64") } # just returns a vector of length nunique of counts of the values @@ -331,9 +326,13 @@ nunique <- as.integer(nunique) n <- nunique } - if (is.null(hashbits)) - hashbits <- as.integer(ceiling(log2(n*minfac))) - else + if (is.null(hashbits)){ + minlen <- ceiling(n*minfac) + if (minlen > 0L) + hashbits <- as.integer(ceiling(log2(minlen))) + else + hashbits <- 0L + }else hashbits <- as.integer(hashbits) nhash <- as.integer(2^hashbits) hashmap <- integer(nhash) @@ -352,9 +351,13 @@ nunique <- as.integer(nunique) n <- nunique } - if (is.null(hashbits)) - hashbits <- as.integer(ceiling(log2(n*minfac))) - else + if (is.null(hashbits)){ + minlen <- ceiling(n*minfac) + if (minlen > 0L) + hashbits <- as.integer(ceiling(log2(minlen))) + else + hashbits <- 0L + }else hashbits <- as.integer(hashbits) nhash <- as.integer(2^hashbits) hashmap <- integer(nhash) @@ -362,7 +365,101 @@ .Call(C_hashmapupo_integer64, x, hashbits, hashmap, nunique, PACKAGE = "bit64") } + +#! \name{runif64} +#! \alias{runif64} +#! \title{ +#! integer64: random numbers +#! } +#! \description{ +#! Create uniform random 64-bit integers within defined range +#! } +#! \usage{ +#! runif64(n, min = lim.integer64()[1], max = lim.integer64()[2], replace=TRUE) +#! } +#! \arguments{ +#! \item{n}{ length of return vector } +#! \item{min}{ lower inclusive bound for random numbers } +#! \item{max}{ upper inclusive bound for random numbers } +#! \item{replace}{ set to FALSE for sampleing from a finite pool, see \code{\link{sample}} } +#! } +#! \value{ +#! a integer64 vector +#! } +#! \details{ +#! For each random integer we call R's internal C interface \code{unif_rand()} twice. +#! Each call is mapped to 2^32 unsigned integers. The two 32-bit patterns are concatenated +#! to form the new integer64. This process is repeated until the result is not a \code{NA_INTEGER64}. +#! } +#! \author{ +#! Jens Oehlschlägel +#! } +#! \keyword{ classes } +#! \keyword{distribution} +#! \keyword{sysdata} +#! \seealso{ +#! \code{\link{runif}}, \code{\link{hashfun}} +#! } +#! \examples{ +#! runif64(12) +#! runif64(12, -16, 16) +#! runif64(12, 0, as.integer64(2^60)-1) # not 2^60-1 ! +#! var(runif(1e4)) +#! var(as.double(runif64(1e4, 0, 2^40))/2^40) # ~ = 1/12 = .08333 +#! +#! table(sample(16, replace=FALSE)) +#! table(runif64(16, 1, 16, replace=FALSE)) +#! table(sample(16, replace=TRUE)) +#! table(runif64(16, 1, 16, replace=TRUE)) +#! } + +runif64 <- function(n, min=lim.integer64()[1], max=lim.integer64()[2], replace = TRUE){ + n <- as.integer(n) + min <- as.integer64(min) + max <- as.integer64(max) + if (replace){ + ret <- .Call(C_runif_integer64, n, min, max) + oldClass(ret) <- "integer64" + }else{ + N <- n + d <- max - min + 1L + if (!is.na(d) && N > d) + stop("cannot take a sample larger than the population when 'replace = FALSE'") + if (!is.na(d) && n > d / (2*log(n,64))){ + ret <- .Call(C_runif_integer64, as.integer(d), as.integer64(min), as.integer64(max)) + oldClass(ret) <- "integer64" + ret <- sample(ret, n, FALSE) + }else{ + ret <- integer64() + while (N > 0){ + ret <- unique(c(ret, Recall( + if (N*1.05 < .Machine$integer.max) N*1.05 else N + , min + , max + , replace=TRUE + ))) + N <- n - length(ret) + } + if (N != 0L) + ret <- ret[1:n] + } + } + ret +} + if (FALSE){ + + require(bit64) + require(microbenchmark) + n <- 1e6 + print(microbenchmark(runif64(n, 1, n), times=20)) + for (m in c(1,2,4,8,16)){ + print(microbenchmark(runif64(n, 1, n*m, replace=FALSE), times=20)) + print(microbenchmark(sample(n*m, n, replace=FALSE), times=20)) + } + print(microbenchmark(runif64(n, 1, replace=FALSE), times=20)) + + library(bit64) n <- 1e7 x <- as.integer64(sample(n, n, TRUE)) @@ -407,4 +504,28 @@ length(t2) + + + library(bit64) + n <- 1e6 + r <- runif64(n, lim.integer64()[1], lim.integer64()[2]) + identical(r, as.integer64(as.bitstring(r))) + cbind(r,as.integer64(as.bitstring(r))) + cbind(as.bitstring(r),as.bitstring(as.integer64(as.bitstring(r)))) + + #sum(duplicated(r)) + #table.integer64(r) + #range(r) + log2(abs(range(r))) + + x <- seq(0,1,0.1) + y <- quantile.integer64(r, x) + z <- diff(y) + plot(log2(z), type="b",ylim=c(0, max(log2(z)))) + + + n <- 1e7 + system.time(runif(n)) + system.time(runif64(n)) + } diff -Nru r-cran-bit64-0.9-7.1/R/highlevel64.R r-cran-bit64-4.0.5/R/highlevel64.R --- r-cran-bit64-0.9-7.1/R/highlevel64.R 2017-05-07 18:05:53.000000000 +0000 +++ r-cran-bit64-4.0.5/R/highlevel64.R 2020-06-14 15:15:59.000000000 +0000 @@ -1515,7 +1515,8 @@ match.integer64 <- function(x, table, nomatch = NA_integer_, nunique=NULL, method=NULL, ...){ - stopifnot(is.integer64(x) && is.integer64(table)) # xx TODO + stopifnot(is.integer64(x)) + table <- as.integer64(table) c <- cache(table) if (is.null(method)){ if (is.null(c)){ @@ -1609,7 +1610,8 @@ "%in%.integer64" <- function(x, table, ...){ - stopifnot(is.integer64(x) && is.integer64(table)) # xx TODO + stopifnot(is.integer64(x)) + table <- as.integer64(table) nunique <- NULL method <- NULL c <- cache(table) @@ -2880,6 +2882,7 @@ #! qtile(x, probs=seq(0, 1, 0.25), \dots) #! \method{qtile}{integer64}(x, probs = seq(0, 1, 0.25), names = TRUE, method = NULL, \dots) #! \method{quantile}{integer64}(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type=0L, \dots) +#! \method{median}{integer64}(x, na.rm = FALSE, \dots) #! \method{mean}{integer64}(x, na.rm = FALSE, \dots) #! \method{summary}{integer64}(object, \dots) #! ## mean(x, na.rm = FALSE, ...) @@ -3031,8 +3034,7 @@ # s # } mean.integer64 <- function(x, na.rm=FALSE, ...){ - ret <- double(1) - .Call(C_mean_integer64, x, as.logical(na.rm), ret) + ret <- .Call(C_mean_integer64, x, as.logical(na.rm), double(1)) oldClass(ret) <- "integer64" ret } diff -Nru r-cran-bit64-0.9-7.1/R/integer64.R r-cran-bit64-4.0.5/R/integer64.R --- r-cran-bit64-0.9-7.1/R/integer64.R 2017-05-07 18:05:55.000000000 +0000 +++ r-cran-bit64-4.0.5/R/integer64.R 2020-08-07 13:00:35.000000000 +0000 @@ -111,8 +111,8 @@ #! to new or old vectors, which helps to avoid unnecessary memory allocation, unnecessary copying and unnessary garbage collection. #! Prior to 0.93 \emph{within} our R functions we also deviated from conventional R programming by not using \code{\link{attr<-}} and \code{\link{attributes<-}} #! because they always did new memory allocation and copying in older R versions. If we wanted to set attributes of return values that we have freshly created, -#! we instead used functions \code{\link[bit]{setattr}} and \code{\link[bit]{setattributes}} from package \code{\link[bit]{bit}}. -#! From version 0.93 \code{\link[bit]{setattr}} is only used for manipulating \code{\link{cache}} objects, in \code{\link{ramsort.integer64}} and \code{\link{sort.integer64}} and in \code{\link{as.data.frame.integer64}}. +#! we instead used functions \code{\link[bit:getsetattr]{setattr}} and \code{\link[bit:getsetattr]{setattributes}} from package \code{\link[bit]{bit}}. +#! From version 0.93 \code{\link[bit:getsetattr]{setattr}} is only used for manipulating \code{\link{cache}} objects, in \code{\link{ramsort.integer64}} and \code{\link{sort.integer64}} and in \code{\link{as.data.frame.integer64}}. #! } #! \section{Arithmetic precision and coercion}{ #! The fact that we introduce 64 bit long long integers -- without introducing 128-bit long doubles -- creates some subtle challenges: @@ -166,7 +166,7 @@ #! The methods \code{\link{is.integer64}} and \code{\link{is.vector}} both return \code{TRUE} for \code{integer64}. #! Note that we did not patch \code{\link{storage.mode}} and \code{\link{typeof}}, which both continue returning 'double' #! Like for 32 bit \code{\link{integer}}, \code{\link{mode}} returns 'numeric' and \code{\link{as.double}}) tries coercing to \code{\link{double}}). -#! It is likely that 'integer64' becomes a \code{\link[ff]{vmode}} in package \code{\link[ff]{ff}}. +#! It is possible that 'integer64' becomes a \code{vmode} in package \code{ff}. #! \cr #! Further methods for creating \code{integer64} are \code{\link[=range.integer64]{range}} which returns the range of the data type if calles without arguments, #! \code{\link[=rep.integer64]{rep}}, \code{\link[=seq.integer64]{seq}}. @@ -178,6 +178,7 @@ #! \bold{creating,testing,printing} \tab \bold{see also} \tab \bold{description} \cr #! \code{NA_integer64_} \tab \code{\link{NA_integer_}} \tab NA constant \cr #! \code{integer64} \tab \code{\link{integer}} \tab create zero atomic vector \cr +#! \code{\link{runif64}} \tab \code{\link{runif}} \tab create random vector \cr #! \code{\link{rep.integer64}} \tab \code{\link{rep}} \tab \cr #! \code{\link{seq.integer64}} \tab \code{\link{seq}} \tab \cr #! \code{\link{is.integer64}} \tab \code{\link{is}} \tab \cr @@ -199,6 +200,7 @@ #! \cr #! \bold{coercing to integer64} \tab \bold{see also} \tab \bold{description} \cr #! \code{\link{as.integer64}} \tab \tab generic \cr +#! \code{\link{as.integer64.bitstring}} \tab \code{\link{as.bitstring}} \tab \cr #! \code{\link{as.integer64.character}} \tab \code{\link{character}} \tab \cr #! \code{\link{as.integer64.double}} \tab \code{\link{double}} \tab \cr #! \code{\link{as.integer64.integer}} \tab \code{\link{integer}} \tab \cr @@ -300,6 +302,7 @@ #! \code{\link{quantile.integer64}} \tab \code{\link{quantile}} \tab (existing) values at specified percentiles (/s/o/so) \cr #! \code{\link{median.integer64}} \tab \code{\link{median}} \tab (existing) value at percentile 0.5 (/s/o/so) \cr #! \code{\link{summary.integer64}} \tab \code{\link{summary}} \tab (/s/o/so) \cr +#! \code{\link{all.equal.integer64}} \tab \code{\link{all.equal}} \tab test if two objects are (nearly) equal (/s/o/so) \cr #! \cr #! \bold{helper functions} \tab \bold{see also} \tab \bold{description} \cr #! \code{\link{minusclass}} \tab \code{\link{minusclass}} \tab removing class attritbute \cr @@ -320,7 +323,7 @@ #! \section{Limitations inherited from implementing 64 bit integers via an external package}{ #! \itemize{ #! \item \bold{vector size} of atomic vectors is still limited to \code{\link{.Machine}$integer.max}. -#! However, external memory extending packages such as \code{\link[ff]{ff}} or \code{bigmemory} +#! However, external memory extending packages such as \code{ff} or \code{bigmemory} #! can extend their address space now with \code{integer64}. Having 64 bit integers also help #! with those not so obvious address issues that arise once we exchange data with SQL databases #! and datawarehouses, which use big integers as surrogate keys, e.g. on indexed primary key columns. @@ -518,7 +521,7 @@ #! stopifnot(identical.integer64(i64-1+1,i64)) #! stopifnot(identical.integer64(i64+1-1,i64)) #! -#! message("Testing minus and plus edge cases and 'rev'\n") +#! message("Testing minus and plus edge cases and 'rev'\nUBSAN signed integer overflow expected for type 'long long int'\nThis is a false UBSAN alarm because overflow is detected and NA returned") #! stopifnot(identical.integer64(lim.integer64()+1-1, c(lim.integer64()[1], NA))) #! stopifnot(identical.integer64(rev(lim.integer64())-1+1, c(lim.integer64()[2], NA))) #! @@ -945,6 +948,7 @@ #! \alias{as.integer.integer64} #! \alias{as.logical.integer64} #! \alias{as.bitstring} +#! \alias{print.bitstring} #! \alias{as.bitstring.integer64} #! \alias{as.factor.integer64} #! \alias{as.ordered.integer64} @@ -960,6 +964,7 @@ #! \usage{ #! as.bitstring(x, \dots) #! \method{as.bitstring}{integer64}(x, \dots) +#! \method{print}{bitstring}(x, \dots) #! \method{as.character}{integer64}(x, \dots) #! \method{as.double}{integer64}(x, keep.names = FALSE, \dots) #! \method{as.integer}{integer64}(x, \dots) @@ -973,7 +978,7 @@ #! \item{\dots}{ further arguments to the \code{\link{NextMethod}} } #! } #! \value{ -#! \code{as.bitstring} returns a string of . \cr +#! \code{as.bitstring} returns a string of class 'bitstring'. \cr #! The other methods return atomic vectors of the expected types #! } #! \author{ @@ -985,12 +990,16 @@ #! \examples{ #! as.character(lim.integer64()) #! as.bitstring(lim.integer64()) +#! as.bitstring(as.integer64(c( +#! -2,-1,NA,0:2 +#! ))) #! } #! \name{as.integer64.character} #! \alias{as.integer64} #! \alias{as.integer64.integer64} #! \alias{as.integer64.NULL} +#! \alias{as.integer64.bitstring} #! \alias{as.integer64.character} #! \alias{as.integer64.double} #! \alias{as.integer64.integer} @@ -1009,6 +1018,7 @@ #! \method{as.integer64}{integer64}(x, \dots) #! \method{as.integer64}{NULL}(x, \dots) #! \method{as.integer64}{character}(x, \dots) +#! \method{as.integer64}{bitstring}(x, \dots) #! \method{as.integer64}{double}(x, keep.names = FALSE, \dots) #! \method{as.integer64}{integer}(x, \dots) #! \method{as.integer64}{logical}(x, \dots) @@ -1021,7 +1031,12 @@ #! } #! \details{ #! \code{as.integer64.character} is realized using C function \code{strtoll} which does not support scientific notation. -#! Instead of '1e6' use '1000000'. +#! Instead of '1e6' use '1000000'. +#! \code{as.integer64.bitstring} evaluates characters '0' anbd ' ' as zero-bit, +#! all other one byte characters as one-bit, +#! multi-byte characters are not allowed, +#! strings shorter than 64 characters are treated as if they were left-padded with '0', +#! strings longer than 64 bytes are mapped to \code{NA_INTEGER64} and a warning is emitted. #! } #! \value{ #! The other methods return atomic vectors of the expected types @@ -1033,7 +1048,25 @@ #! \keyword{ manip } #! \seealso{ \code{\link{as.character.integer64}} \code{\link{integer64}} } #! \examples{ -#! as.integer64(as.character(lim.integer64())) +#! as.integer64(as.character(lim.integer64())) +#! as.integer64( +#! structure(c("1111111111111111111111111111111111111111111111111111111111111110", +#! "1111111111111111111111111111111111111111111111111111111111111111", +#! "1000000000000000000000000000000000000000000000000000000000000000", +#! "0000000000000000000000000000000000000000000000000000000000000000", +#! "0000000000000000000000000000000000000000000000000000000000000001", +#! "0000000000000000000000000000000000000000000000000000000000000010" +#! ), class = "bitstring") +#! ) +#! as.integer64( +#! structure(c("............................................................... ", +#! "................................................................", +#! ". ", +#! "", +#! ".", +#! "10" +#! ), class = "bitstring") +#! ) #! } @@ -1049,13 +1082,14 @@ #! Methods to extract and replace parts of an integer64 vector. #! } #! \usage{ -#! \method{[}{integer64}(x, \dots) +#! \method{[}{integer64}(x, i, \dots) #! \method{[}{integer64}(x, \dots) <- value #! \method{[[}{integer64}(x, \dots) #! \method{[[}{integer64}(x, \dots) <- value #! } #! \arguments{ #! \item{x}{ an atomic vector } +#! \item{i}{ indices specifying elements to extract } #! \item{value}{ an atomic vector with values to be assigned } #! \item{\dots}{ further arguments to the \code{\link{NextMethod}} } #! } @@ -1079,6 +1113,10 @@ #! x #! x[] #! x[,2:3] +#! \dontshow{ +#! r <- c(runif64(1e3, lim.integer64()[1], lim.integer64()[2]), NA, -2:2) +#! stopifnot(identical(r, as.integer64(as.bitstring(r)))) +#! } #! } #! \name{format.integer64} @@ -1152,8 +1190,15 @@ #! \seealso{ \code{\link{xor.integer64}} \code{\link{integer64}} } #! \examples{ #! sqrt(as.integer64(1:12)) +#! \dontshow{ +#! i <- -999:999 +#! for (s in -3:3){ +#! r <- as.integer64(round(as.integer(i), s)) +#! r64 <- round(as.integer64(i), s) +#! stopifnot(identical(r,r64)) +#! } +#! } #! } - #! \name{xor.integer64} #! \alias{&.integer64} @@ -1243,7 +1288,7 @@ #! \method{any}{integer64}(\dots, na.rm = FALSE) #! \method{min}{integer64}(\dots, na.rm = FALSE) #! \method{max}{integer64}(\dots, na.rm = FALSE) -#! \method{range}{integer64}(\dots, na.rm = FALSE) +#! \method{range}{integer64}(\dots, na.rm = FALSE, finite = FALSE) #! lim.integer64() #! \method{sum}{integer64}(\dots, na.rm = FALSE) #! \method{prod}{integer64}(\dots, na.rm = FALSE) @@ -1251,6 +1296,7 @@ #! \arguments{ #! \item{\dots}{ atomic vectors of class 'integer64'} #! \item{na.rm}{ logical scalar indicating whether to ignore NAs } +#! \item{finite}{ logical scalar indicating whether to ignore NAs (just for compatibility with \code{\link{range.default}}) } #! } #! \details{ #! The numerical summary methods always return \code{integer64}. @@ -1515,6 +1561,79 @@ #! } +#! \name{all.equal.integer64} +#! \alias{all.equal.integer64} +#! \title{ +#! Test if two integer64 vectors are all.equal +#! } +#! \description{ +#! A utility to compare integer64 objects 'x' and 'y' testing for ‘near equality’, see \code{\link{all.equal}}. +#! } +#! \usage{ +#! \method{all.equal}{integer64}( +#! target +#! , current +#! , tolerance = sqrt(.Machine$double.eps) +#! , scale = NULL +#! , countEQ = FALSE +#! , formatFUN = function(err, what) format(err) +#! , ... +#! , check.attributes = TRUE +#! ) +#! } +#! \arguments{ +#! \item{target}{ a vector of 'integer64' or an object that can be coerced with \code{\link{as.integer64}} } +#! \item{current}{ a vector of 'integer64' or an object that can be coerced with \code{\link{as.integer64}} } +#! \item{tolerance}{numeric \eqn{\ge} 0. Differences smaller than +#! \code{tolerance} are not reported. The default value is close to +#! \code{1.5e-8}.} +#! \item{scale}{\code{NULL} or numeric > 0, typically of length 1 or +#! \code{length(target)}. See \sQuote{Details}.} +#! \item{countEQ}{logical indicating if the \code{target == current} +#! cases should be counted when computing the mean (absolute or +#! relative) differences. The default, \code{FALSE} may seem +#! misleading in cases where \code{target} and \code{current} only +#! differ in a few places; see the extensive example.} +#! \item{formatFUN}{a \code{\link{function}} of two arguments, +#! \code{err}, the relative, absolute or scaled error, and +#! \code{what}, a character string indicating the \emph{kind} of error; +#! maybe used, e.g., to format relative and absolute errors differently.} +#! \item{\dots}{further arguments are ignored} +#! \item{check.attributes}{logical indicating if the +#! \code{\link{attributes}} of \code{target} and \code{current} +#! (other than the names) should be compared.} +#! } +#! \value{ +#! Either ‘TRUE’ (‘NULL’ for ‘attr.all.equal’) or a vector of ‘mode’ +#! ‘"character"’ describing the differences between ‘target’ and +#! ‘current’. +#! } +#! \details{ +#! In \code{\link{all.equal.numeric}} the type \code{integer} is treated as a proper subset of \code{double} +#! i.e. does not complain about comparing \code{integer} with \code{double}. +#! Following this logic \code{all.equal.integer64} treats \code{integer} as a proper subset of \code{integer64} +#! and does not complain about comparing \code{integer} with \code{integer64}. \code{double} also compares without warning +#! as long as the values are within \code{\link{lim.integer64}}, if \code{double} are bigger \code{all.equal.integer64} +#! complains about the \code{all.equal.integer64 overflow warning}. For further details see \code{\link{all.equal}}. +#! } +#! \note{ +#! \code{\link{all.equal}} only dispatches to this method if the first argument is \code{integer64}, +#! calling \code{\link{all.equal}} with a \code{non-integer64} first and a \code{integer64} second argument +#! gives undefined behavior! +#! } +#! \author{ +#! Leonardo Silvestri (for package nanotime) +#! } +#! \seealso{ +#! \code{\link{all.equal}} +#! } +#! \examples{ +#! all.equal(as.integer64(1:10), as.integer64(0:9)) +#! all.equal(as.integer64(1:10), as.integer(1:10)) +#! all.equal(as.integer64(1:10), as.double(1:10)) +#! all.equal(as.integer64(1), as.double(1e300)) +#! } + # if (!exists(":.default")){ # ":.default" <- get(":") # ":" <- function(from,to)UseMethod(":") @@ -1523,6 +1642,149 @@ setOldClass("integer64") +# contributed by Leonardo Silvestri with modifications of JO +all.equal.integer64 <- function ( + target +, current +, tolerance = sqrt(.Machine$double.eps) +, scale = NULL +, countEQ = FALSE +, formatFUN = function(err, what) format(err) +, ... +, check.attributes = TRUE +) +{ + if (!is.numeric(tolerance)) + stop("'tolerance' should be numeric") + if (!is.numeric(scale) && !is.null(scale)) + stop("'scale' should be numeric or NULL") + if (!is.logical(check.attributes)) + stop(gettextf("'%s' must be logical", "check.attributes"), + domain = NA) + # JO: BEGIN respect that integer is a proper subset of integer64 like integer is a proper subset of double + oldwarn <- getOption("warn") + on.exit(options(warn=oldwarn)) + options(warn=2L) + if (!is.integer64(target)){ + cl <- oldClass(target) + oldClass(target) <- NULL + target <- try(as.integer64(target)) + if (inherits(target, 'try-error')) + return(paste("while coercing 'target' to 'integer64':", attr(target, "condition")$message)) + oldClass(target) <- c(cl, "integer64") + } + if (!is.integer64(current)){ + cl <- oldClass(current) + oldClass(current) <- NULL + current <- try(as.integer64(current)) + if (inherits(current, 'try-error')) + return(paste("while coercing 'current' to 'integer64':", attr(current, "condition")$message)) + oldClass(current) <- c(cl, "integer64") + } + # JO: END respect that integer is a proper subset of integer64 like integer is a proper subset of double + msg <- NULL + msg <- if (check.attributes) + attr.all.equal(target, current, tolerance = tolerance, + scale = scale, ...) + if (data.class(target) != data.class(current)) { + msg <- c(msg, paste0("target is ", data.class(target), + ", current is ", data.class(current))) + return(msg) + } + lt <- length(target) + lc <- length(current) + if (lt != lc) { + if (!is.null(msg)) + msg <- msg[-grep("\\bLengths\\b", msg)] + msg <- c(msg, paste0("integer64: lengths (", lt, ", ", lc, ") differ")) + return(msg) + } + out <- is.na(target) + if (any(out != is.na(current))) { + msg <- c(msg, paste("'is.NA' value mismatch:", sum(is.na(current)), + "in current", sum(out), "in target")) + return(msg) + } + out <- out | target == current + if (all(out)) + return(if (is.null(msg)) TRUE else msg) + if (countEQ) { + N <- length(out) + sabst0 <- sum(abs(target[out])) + } else { + sabst0 <- 0 + } + target <- target[!out] + current <- current[!out] + if (!countEQ) + N <- length(target) + xy <- sum(abs(target - current))/N + what <- if (is.null(scale)) { + xn <- (sabst0 + sum(abs(target)))/N + if (is.finite(xn) && xn > tolerance) { + xy <- xy/xn + "relative" + } else { + "absolute" + } + } else { + stopifnot(all(scale > 0)) + xy <- xy/scale + if (all(abs(scale - 1) < 1e-07)) + "absolute" + else "scaled" + } + if (is.na(xy) || xy > tolerance) + msg <- c(msg, paste("Mean", what, "difference:", formatFUN(xy, what))) + if (is.null(msg)) { + TRUE + } else msg +} + +if (FALSE){ + require(bit64) + a <- as.integer64(1) + b <- as.integer(10) + oldClass(a) <- c("j", oldClass(a)) + oldClass(b) <- c("j", oldClass(b)) + all.equal(a,b) + + a <- as.double(1) + b <- as.integer(10) + oldClass(a) <- c("j", oldClass(a)) + oldClass(b) <- c("j", oldClass(b)) + all.equal(a,b) + + a <- as.integer64(9e17) + b <- 9e18 + oldClass(a) <- c("j", oldClass(a)) + oldClass(b) <- c("j", oldClass(b)) + all.equal(a,b) + + a <- as.integer64(9e18) + b <- 9e19 + oldClass(a) <- c("j", oldClass(a)) + oldClass(b) <- c("j", oldClass(b)) + all.equal(a,b) + + a <- as.integer64(c(1,NA)) + b <- as.integer(c(1,NA)) + all.equal(a,b) + + a <- as.integer64(c(1,NA)) + b <- as.double(c(1,NA)) + all.equal(a,b) + + a <- as.integer64(c(1,Inf)) + b <- as.integer(c(1,Inf)) + all.equal(a,b) + + a <- as.integer64(c(1,Inf)) + b <- as.double(c(1,Inf)) + all.equal(a,b) +} + + identical.integer64 <- function(x, y , num.eq = FALSE , single.NA = FALSE @@ -1567,43 +1829,138 @@ whichclass } -binattr <- function(e1,e2){ +if (FALSE){ + # version until 0.9-7 + binattr <- function(e1,e2){ + d1 <- dim(e1) + d2 <- dim(e2) + n1 <- length(e1) + n2 <- length(e2) + if (length(d1)){ + if (length(d2)){ + if (!identical(dim(e1),dim(e2))) + stop("non-conformable arrays") + }else{ + if (n2>n1) + stop("length(e2) does not match dim(e1)") + if (n1%%n2) + warning("length(e1) not a multiple length(e2)") + } + attributes(e1) + }else{ + if (length(d2)){ + if (n1>n2) + stop("length(e1) does not match dim(n2)") + if (n2%%n1) + warning("length(e2) not a multiple length(e1)") + attributes(e2) + }else{ + if (n1n1) - stop("length(e2) does not match dim(e1)") - if (n1%%n2) - warning("length(e1) not a multiple length(e2)") - } - attributes(e1) - }else{ - if (length(d2)){ - if (n1>n2) - stop("length(e1) does not match dim(n2)") - if (n2%%n1) - warning("length(e2) not a multiple length(e1)") - attributes(e2) - }else{ - if (n1 n1 && n1) + stop("length(e2) does not match dim(e1)") + if (n2 && n1 %% n2) + warning("length(e1) not a multiple length(e2)") + } + } else{ + if (length(d2)) { + if (n1 > n2 && n2) + stop("length(e1) does not match dim(n2)") + if (n1 && n2 %% n1) + warning("length(e2) not a multiple length(e1)") + } else{ + if (n1 < n2 && n1) { + if (n1 && n2 %% n1) + warning("length(e2) not a multiple length(e1)") + } else{ + if (n2 && n1 %% n2) + warning("length(e1) not a multiple length(e2)") + } + } + } + + ## in this part we mimic R's algo for selecting attributes: + if (n1 == n2){ + ## if same size take attribute from e1 if it exists, else from e2 + if (n1==0){ + ae1 <- attributes(e1)[c("class","dim","dimnames")] + ae2 <- attributes(e2)[c("class","dim","dimnames")] + } + ae1 <- attributes(e1) + ae2 <- attributes(e2) + nae1 <- names(attributes(e1)) + nae2 <- names(attributes(e2)) + if (n1==0){ + ae1 <- ae1[nae1 %in% c("class","dim","dimnames")] + ae2 <- ae1[nae1 %in% c("class","dim","dimnames")] + } + allattr <- list() + for (a in union(nae1, nae2)) + if (a %in% nae1) + allattr[[a]] <- ae1[[a]] + else + allattr[[a]] <- ae2[[a]] + allattr + }else if (n1 == 0 || n1 > n2) { + attributes(e1) + } else { + attributes(e2) } } +if (FALSE){ + x <- integer64(0) + y <- integer64(0) + #dim(x) <- c(2L,2L) + dim(y) <- c(0L,0L) + dimnames(y) <- list(character(0),character(0)) + #dim(x) <- c(1L,4L) + #dim(y) <- c(4L,1L) + + attr(x,"x") <- "x" + attr(y,"y") <- "y" + + z <- x - y + z + dim(z) + dimnames(z) + + z <- y - x + z + dim(z) + dimnames(z) + + ret <- "integer64(0)" + attributes(ret) <- list(dim = c(0L, 0L), class = character(0), dimnames = list(NULL,NULL)) + +} + integer64 <- function(length=0){ ret <- double(length) oldClass(ret) <- "integer64" @@ -1621,8 +1978,7 @@ as.integer64.integer64 <- function(x, ...)x as.integer64.double <- function(x, keep.names=FALSE, ...){ - ret <- double(length(x)) - .Call(C_as_integer64_double, x, ret) + ret <- .Call(C_as_integer64_double, x, double(length(x))) if (keep.names) names(ret) <- names(x) oldClass(ret) <- "integer64" @@ -1630,16 +1986,14 @@ } as.integer64.logical <- as.integer64.integer <- function(x, ...){ - ret <- double(length(x)) - .Call(C_as_integer64_integer, x, ret) + ret <- .Call(C_as_integer64_integer, x, double(length(x))) oldClass(ret) <- "integer64" ret } as.integer64.character <- function(x, ...){ n <- length(x) - ret <- rep(as.double(NA), n) - .Call(C_as_integer64_character, x, ret) + ret <- .Call(C_as_integer64_character, x, rep(as.double(NA), n)) oldClass(ret) <- "integer64" ret } @@ -1648,39 +2002,45 @@ as.integer64(unclass(x), ...) as.double.integer64 <- function(x, keep.names=FALSE, ...){ - ret <- double(length(x)) - .Call(C_as_double_integer64, x, ret) + ret <- .Call(C_as_double_integer64, x, double(length(x))) if (keep.names) names(ret) <- names(x) ret } as.integer.integer64 <- function(x, ...){ - ret <- integer(length(x)) - .Call(C_as_integer_integer64, x, ret) - ret + .Call(C_as_integer_integer64, x, integer(length(x))) } as.logical.integer64 <- function(x, ...){ - ret <- logical(length(x)) - .Call(C_as_logical_integer64, x, ret) - ret + .Call(C_as_logical_integer64, x, logical(length(x))) } as.character.integer64 <- function(x, ...){ n <- length(x) - ret <- rep(as.character(NA), n) - .Call(C_as_character_integer64, x, ret) - ret + .Call(C_as_character_integer64, x, rep(as.character(NA), n)) } as.bitstring.integer64 <- function(x, ...){ n <- length(x) - ret <- rep(as.character(NA), n) - .Call(C_as_bitstring_integer64, x, ret) + ret <- .Call(C_as_bitstring_integer64, x, rep(as.character(NA), n)) + oldClass(ret) <- 'bitstring' ret } +print.bitstring <- function(x, ...){ + oldClass(x) <- minusclass(class(x), 'bitstring') + NextMethod(x) +} + +as.integer64.bitstring <- function(x, ...){ + n <- length(x) + ret <- .Call(C_as_integer64_bitstring, x, double(length(x))) + oldClass(ret) <- "integer64" + ret +} + + # read.table expects S4 as() setAs("character","integer64",function(from)as.integer64.character(from)) setAs("integer64","character",function(from)as.character.integer64(from)) @@ -1717,12 +2077,16 @@ } print.integer64 <- function(x, quote=FALSE, ...){ - cat("integer64\n") a <- attributes(x) - ret <- as.character(x) - a$class <- minusclass(a$class, "integer64") - attributes(ret) <- a - print(ret, quote=quote, ...) + if (length(x)){ + cat("integer64\n") + ret <- as.character(x) + a$class <- minusclass(a$class, "integer64") + attributes(ret) <- a + print(ret, quote=quote, ...) + }else{ + cat("integer64(0)\n") + } invisible(x) } @@ -1741,14 +2105,53 @@ invisible() } -"[.integer64" <- function(x,...){ - cl <- oldClass(x) - ret <- NextMethod() - oldClass(ret) <- cl - remcache(ret) - ret +if (FALSE){ + require(microbenchmark) + require(bit64) + x <- runif64(1e7) + microbenchmark(x[TRUE], times=10) + microbenchmark(x[NA], times=10) + i <- seq_along(x) + i[1] <- NA + microbenchmark(x[i], times=10) + i <- rep(TRUE, length(x)) + i[1] <- NA + microbenchmark(x[i], times=10) + i <- seq_along(x) + microbenchmark(x[i], times=10) + i <- rep(TRUE, length(x)) + microbenchmark(x[i], times=10) + } + +"[.integer64" <- function(x, i, ...){ + cl <- oldClass(x) + ret <- NextMethod() + # Begin NA-handling from Leonardo Silvestri + if (!missing(i)){ + if (class(i) == "character") { + na_idx <- union(which(!(i %in% names(x))), which(is.na(i))) + if (length(na_idx)) + ret[na_idx] <- NA_integer64_ + }else{ + if (class(i) == "logical"){ + i <- i[is.na(i) | i] + na_idx <- rep(is.na(i), length.out=length(ret)) + }else{ + na_idx <- is.na(i) + } + if (any(na_idx)) + ret[na_idx] <- NA_integer64_ + } + } + # End NA-handling from Leonardo Silvestri + oldClass(ret) <- cl + remcache(ret) + ret +} + + "[<-.integer64" <- function(x,...,value){ cl <- oldClass(x) value <- as.integer64(value) @@ -1860,8 +2263,7 @@ ":.integer64" <- function(from, to){ from <- as.integer64(from) to <- as.integer64(to) - ret <- double(as.integer(to-from+1L)) - .Call(C_seq_integer64, from, as.integer64(1L), ret) + ret <- .Call(C_seq_integer64, from, as.integer64(1L), double(as.integer(to-from+1L))) oldClass(ret) <- "integer64" ret } @@ -1907,8 +2309,7 @@ return(from) else{ #return(cumsum(c(from, rep(by, length.out-1L)))) - ret <- double(as.integer(length.out)) - .Call(C_seq_integer64, from, by, ret) + ret <- .Call(C_seq_integer64, from, by, double(as.integer(length.out))) oldClass(ret) <- "integer64" return(ret) } @@ -1923,8 +2324,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- double(max(length(e1),length(e2))) - .Call(C_plus_integer64, e1, e2, ret) + ret <- .Call(C_plus_integer64, e1, e2, double(max(length(e1),length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1938,8 +2338,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- double(max(length(e1),length(e2))) - .Call(C_minus_integer64, e1, e2, ret) + ret <- .Call(C_minus_integer64, e1, e2, double(max(length(e1),length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1949,8 +2348,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- double(max(length(e1), length(e2))) - .Call(C_intdiv_integer64, e1, e2, ret) + ret <- .Call(C_intdiv_integer64, e1, e2, double(max(length(e1), length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1960,8 +2358,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- double(max(length(e1), length(e2))) - .Call(C_mod_integer64, e1, e2, ret) + ret <- .Call(C_mod_integer64, e1, e2, double(max(length(e1), length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1970,11 +2367,10 @@ "*.integer64" <- function(e1, e2){ a <- binattr(e1,e2) - ret <- double(max(length(e1),length(e2))) if (is.double(e2)) # implies !is.integer64(e2) - .Call(C_times_integer64_double, as.integer64(e1), e2, ret) + ret <- .Call(C_times_integer64_double, as.integer64(e1), e2, double(max(length(e1),length(e2)))) else - .Call(C_times_integer64_integer64, as.integer64(e1), as.integer64(e2), ret) + ret <- .Call(C_times_integer64_integer64, as.integer64(e1), as.integer64(e2), double(max(length(e1),length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1982,11 +2378,10 @@ "^.integer64" <- function(e1, e2){ a <- binattr(e1,e2) - ret <- double(max(length(e1),length(e2))) if (is.double(e2)) # implies !is.integer64(e2) - .Call(C_power_integer64_double, as.integer64(e1), e2, ret) + ret <- .Call(C_power_integer64_double, as.integer64(e1), e2, double(max(length(e1),length(e2)))) else - .Call(C_power_integer64_integer64, as.integer64(e1), as.integer64(e2), ret) + ret <- .Call(C_power_integer64_integer64, as.integer64(e1), as.integer64(e2), double(max(length(e1),length(e2)))) a$class <- plusclass(a$class, "integer64") attributes(ret) <- a ret @@ -1994,11 +2389,10 @@ "/.integer64" <- function(e1, e2){ a <- binattr(e1,e2) - ret <- double(max(length(e1),length(e2))) if (is.double(e2)) # implies !is.integer64(e2) - .Call(C_divide_integer64_double, as.integer64(e1), e2, ret) + ret <- .Call(C_divide_integer64_double, as.integer64(e1), e2, double(max(length(e1),length(e2)))) else - .Call(C_divide_integer64_integer64, as.integer64(e1), as.integer64(e2), ret) + ret <- .Call(C_divide_integer64_integer64, as.integer64(e1), as.integer64(e2), double(max(length(e1),length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2007,24 +2401,21 @@ "sign.integer64" <- function(x){ a <- attributes(x) - ret <- double(length(x)) - .Call(C_sign_integer64, x,ret) + ret <- .Call(C_sign_integer64, x, double(length(x))) attributes(ret) <- a ret } "abs.integer64" <- function(x){ a <- attributes(x) - ret <- double(length(x)) - .Call(C_abs_integer64, x,ret) + ret <- .Call(C_abs_integer64, x, double(length(x))) attributes(ret) <- a ret } "sqrt.integer64" <- function(x){ a <- attributes(x) - ret <- double(length(x)) - .Call(C_sqrt_integer64, x,ret) + ret <- .Call(C_sqrt_integer64, x, double(length(x))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2032,13 +2423,12 @@ "log.integer64" <- function(x, base=NULL){ a <- attributes(x) - ret <- double(max(length(x),length(base))) - if (is.null(base)) - .Call(C_log_integer64, x, ret) - else if(length(base)==1){ - .Call(C_logbase_integer64, x, as.double(base), ret) + ret <- if (is.null(base)){ + .Call(C_log_integer64, x, double(max(length(x),length(base)))) + }else if(length(base)==1){ + .Call(C_logbase_integer64, x, as.double(base), double(max(length(x),length(base)))) }else{ - .Call(C_logvect_integer64, x, as.double(base), ret) + .Call(C_logvect_integer64, x, as.double(base), double(max(length(x),length(base)))) } a$class <- minusclass(a$class, "integer64") attributes(ret) <- a @@ -2047,8 +2437,7 @@ "log10.integer64" <- function(x){ a <- attributes(x) - ret <- double(length(x)) - .Call(C_log10_integer64, x,ret) + ret <- .Call(C_log10_integer64, x, double(length(x))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2056,8 +2445,7 @@ "log2.integer64" <- function(x){ a <- attributes(x) - ret <- double(length(x)) - .Call(C_log2_integer64, x,ret) + ret <- .Call(C_log2_integer64, x, double(length(x))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2073,63 +2461,62 @@ "round.integer64" <- function(x, digits=0){ if (digits<0){ a <- attributes(x) - base <- 10^floor(-digits) - ret <- (x%/%base) * base + b <- 10^round(-digits) + b2 <- b %/% 2 + d <- (x %/% b) + db <- d * b + r <- abs(x-db) + ret <- ifelse((r < b2) | (r == b2 & ((d %% 2L) == 0L)), db, db + sign(x)*b) #a$class <- minusclass(a$class, "integer64") attributes(ret) <- a - ret + ret }else - x + x } + + + "any.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- logical(1) if (length(l)==1){ - .Call(C_any_integer64, l[[1]], na.rm, ret) - ret + .Call(C_any_integer64, l[[1]], na.rm, logical(1)) }else{ any(sapply(l, function(e){ - if (is.integer64(e)){ - .Call(C_any_integer64, e, na.rm, ret) - ret - }else{ - any(e, na.rm = na.rm) - } + if (is.integer64(e)){ + .Call(C_any_integer64, e, na.rm, logical(1)) + }else{ + any(e, na.rm = na.rm) + } }), na.rm = na.rm) } } "all.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- logical(1) if (length(l)==1){ - .Call(C_all_integer64, l[[1]], na.rm, ret) - ret + .Call(C_all_integer64, l[[1]], na.rm, logical(1)) }else{ all(sapply(l, function(e){ - if (is.integer64(e)){ - .Call(C_all_integer64, e, na.rm, ret) - ret - }else{ - all(e, na.rm = na.rm) - } + if (is.integer64(e)){ + .Call(C_all_integer64, e, na.rm, logical(1)) + }else{ + all(e, na.rm = na.rm) + } }), na.rm = na.rm) } } "sum.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- double(1) if (length(l)==1){ - .Call(C_sum_integer64, l[[1]], na.rm, ret) + ret <- .Call(C_sum_integer64, l[[1]], na.rm, double(1)) oldClass(ret) <- "integer64" ret }else{ ret <- sapply(l, function(e){ if (is.integer64(e)){ - .Call(C_sum_integer64, e, na.rm, ret) - ret + .Call(C_sum_integer64, e, na.rm, double(1)) }else{ as.integer64(sum(e, na.rm = na.rm)) } @@ -2143,16 +2530,14 @@ "prod.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- double(1) if (length(l)==1){ - .Call(C_prod_integer64, l[[1]], na.rm, ret) - oldClass(ret) <- "integer64" - ret + ret <- .Call(C_prod_integer64, l[[1]], na.rm, double(1)) + oldClass(ret) <- "integer64" + ret }else{ ret <- sapply(l, function(e){ if (is.integer64(e)){ - .Call(C_prod_integer64, e, na.rm, ret) - ret + .Call(C_prod_integer64, e, na.rm, double(1)) }else{ as.integer64(prod(e, na.rm = na.rm)) } @@ -2162,50 +2547,48 @@ } } + "min.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- double(1) noval <- TRUE if (length(l)==1){ - if (length(l[[1]])) - noval <- FALSE - .Call(C_min_integer64, l[[1]], na.rm, ret) + if (length(l[[1]])) + noval <- FALSE + ret <- .Call(C_min_integer64, l[[1]], na.rm, double(1)) oldClass(ret) <- "integer64" }else{ - ret <- sapply(l, function(e){ - if (length(e)) - noval <<- FALSE - if (is.integer64(e)){ - .Call(C_min_integer64, e, na.rm, ret) - ret - }else{ - as.integer64(min(e, na.rm = na.rm)) - } - }) - oldClass(ret) <- "integer64" - ret <- min(ret, na.rm = na.rm) + ret <- sapply(l, function(e){ + if (length(e)) + noval <<- FALSE + if (is.integer64(e)){ + .Call(C_min_integer64, e, na.rm, double(1)) + }else{ + as.integer64(min(e, na.rm = na.rm)) + } + }) + oldClass(ret) <- "integer64" + ret <- min(ret, na.rm = na.rm) } if (noval) - warning("no non-NA value, returning +9223372036854775807") + warning("no non-NA value, returning +9223372036854775807") ret } + "max.integer64" <- function(..., na.rm = FALSE){ l <- list(...) - ret <- double(1) noval <- TRUE if (length(l)==1){ if (length(l[[1]])) noval <- FALSE - .Call(C_max_integer64, l[[1]], na.rm, ret) + ret <- .Call(C_max_integer64, l[[1]], na.rm, double(1)) oldClass(ret) <- "integer64" }else{ ret <- sapply(l, function(e){ if (length(e)) noval <<- FALSE if (is.integer64(e)){ - .Call(C_max_integer64, e, na.rm, ret) - ret + .Call(C_max_integer64, e, na.rm, double(1)) }else{ as.integer64(max(e, na.rm = na.rm)) } @@ -2219,22 +2602,22 @@ } -"range.integer64" <- function(..., na.rm = FALSE){ - ret <- double(2) +"range.integer64" <- function(..., na.rm = FALSE, finite = FALSE){ + if (finite) + na.rm = TRUE l <- list(...) noval <- TRUE if (length(l)==1){ if (length(l[[1]])) noval <- FALSE - .Call(C_range_integer64, l[[1]], na.rm, ret) + ret <- .Call(C_range_integer64, l[[1]], na.rm, double(2)) oldClass(ret) <- "integer64" }else{ ret <- unlist(sapply(l, function(e){ if (length(e)) noval <<- FALSE if (is.integer64(e)){ - .Call(C_range_integer64, e, na.rm, ret) - ret + .Call(C_range_integer64, e, na.rm, double(2)) }else{ as.integer64(range(e, na.rm = na.rm)) } @@ -2247,9 +2630,9 @@ ret } + lim.integer64 <- function(){ - ret <- double(2) - .Call(C_lim_integer64, ret) + ret <- .Call(C_lim_integer64, double(2)) oldClass(ret) <- "integer64" return(ret) } @@ -2258,20 +2641,22 @@ lag <- as.integer(lag) n <- length(x) d <- differences <- as.integer(differences) - while(d>0L){ - n <- n - lag - if (n<=0L){ - ret <- double() - break - } - if (d==differences){ - ret <- double(n) + while(d > 0L){ + n <- n - lag + if (n <= 0L){ + ret <- double() + break + } + # not assigning ret<-.Call in the following is intended because faster + if (d==differences){ + ret <- double(n) .Call(C_diff_integer64, x, as.integer64(lag), as.integer64(n), ret) - }else{ - .Call(C_diff_integer64, ret, as.integer64(lag), as.integer64(n), ret) - } - d <- d - 1L + }else{ + .Call(C_diff_integer64, ret, as.integer64(lag), as.integer64(n), ret) + } + d <- d - 1L } + # length of ret is only change once here length(ret) <- n oldClass(ret) <- "integer64" ret @@ -2279,29 +2664,24 @@ "cummin.integer64" <- function(x){ - ret <- double(length(x)) - .Call(C_cummin_integer64, x,ret) + ret <- .Call(C_cummin_integer64, x, double(length(x))) oldClass(ret) <- "integer64" ret } "cummax.integer64" <- function(x){ - - ret <- double(length(x)) - .Call(C_cummax_integer64, x,ret) + ret <- .Call(C_cummax_integer64, x, double(length(x))) oldClass(ret) <- "integer64" ret } "cumsum.integer64" <- function(x){ - ret <- double(length(x)) - .Call(C_cumsum_integer64, x,ret) + ret <- .Call(C_cumsum_integer64, x, double(length(x))) oldClass(ret) <- "integer64" ret } "cumprod.integer64" <- function(x){ - ret <- double(length(x)) - .Call(C_cumprod_integer64, x,ret) + ret <- .Call(C_cumprod_integer64, x, double(length(x))) oldClass(ret) <- "integer64" ret } @@ -2310,8 +2690,7 @@ "is.na.integer64" <- function(x){ a <- attributes(x) - ret <- logical(length(x)) - .Call(C_isna_integer64, x, ret) + ret <- .Call(C_isna_integer64, x, logical(length(x))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2326,8 +2705,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_EQ_integer64, e1, e2, ret) + ret <- .Call(C_EQ_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2337,8 +2715,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_NE_integer64, e1, e2, ret) + ret <- .Call(C_NE_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2348,8 +2725,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_LT_integer64, e1, e2, ret) + ret <- .Call(C_LT_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2359,8 +2735,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_LE_integer64, e1, e2, ret) + ret <- .Call(C_LE_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2370,8 +2745,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_GT_integer64, e1, e2, ret) + ret <- .Call(C_GT_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2381,8 +2755,7 @@ a <- binattr(e1,e2) e1 <- as.integer64(e1) e2 <- as.integer64(e2) - ret <- logical(max(length(e1), length(e2))) - .Call(C_GE_integer64, e1, e2, ret) + ret <- .Call(C_GE_integer64, e1, e2, logical(max(length(e1), length(e2)))) a$class <- minusclass(a$class, "integer64") attributes(ret) <- a ret @@ -2441,3 +2814,4 @@ TRUE } + diff -Nru r-cran-bit64-0.9-7.1/R/patch64.R r-cran-bit64-4.0.5/R/patch64.R --- r-cran-bit64-0.9-7.1/R/patch64.R 2017-04-14 11:07:44.000000000 +0000 +++ r-cran-bit64-4.0.5/R/patch64.R 2020-06-14 15:15:59.000000000 +0000 @@ -1,166 +1,166 @@ -# /* -# R-Code for patching S3 generics -# S3 atomic 64bit integers for R -# (c) 2011 Jens Oehlschägel -# Licence: GPL2 -# Provided 'as is', use at your own risk -# Created: 2011-12-11 -# Last changed: 2011-12-11 -# */ - -#! \name{bit64S3} -#! \alias{bit64S3} -#! \alias{:} -#! \alias{:.default} -#! \alias{:.integer64} -#! \alias{is.double} -#! \alias{is.double.default} -#! \alias{is.double.integer64} -#! \alias{match} -#! \alias{match.default} -#! \alias{\%in\%} -#! \alias{\%in\%.default} -#! \alias{rank} -#! \alias{rank.default} -#! %\alias{table} -#! %\alias{table.default} -#! \alias{order} -#! \alias{order.default} -#! \title{ -#! Tunrning base R functions into S3 generics for bit64 -#! } -#! \description{ -#! Turn those base functions S3 generic which are used in bit64 -#! } -#! \usage{ -#! from:to -#! #--as-cran complains about \method{:}{default}(from, to) -#! #--as-cran complains about \method{:}{integer64}(from, to) -#! is.double(x) -#! \method{is.double}{default}(x) -#! \method{is.double}{integer64}(x) -#! match(x, table, ...) -#! \method{match}{default}(x, table, ...) -#! x \%in\% table -#! \method{\%in\%}{default}(x, table) -#! rank(x, ...) -#! \method{rank}{default}(x, ...) -#! %table(...) -#! %\method{table}{default}(...) -#! order(...) -#! \method{order}{default}(...) -#! } -#! \arguments{ -#! \item{x}{ -#! integer64 vector: the values to be matched, optionally carrying a cache created with \code{\link{hashcache}} -#! } -#! \item{table}{ -#! integer64 vector: the values to be matched against, optionally carrying a cache created with \code{\link{hashcache}} or \code{\link{sortordercache}} -#! } -#! \item{from}{ scalar denoting first element of sequence } -#! \item{to}{ scalar denoting last element of sequence } -#! \item{\dots}{ ignored } -#! } -#! \details{ -#! The following functions are turned into S3 gernerics in order to dispatch methods for \code{\link{integer64}}: -#! \preformatted{ -#! \code{\link{:}} -#! \code{\link{is.double}} -#! \code{\link{match}} -#! \code{\link{\%in\%}} -#! %\code{\link{table}} -#! \code{\link{rank}} -#! \code{\link{order}} -#! } -#! } -#! \value{ -#! \code{\link{invisible}} -#! } -#! \author{ -#! Jens Oehlschlägel -#! } -#! \note{ -#! \code{\link{is.double}} returns \code{FALSE} for \code{\link{integer64}} \cr -#! \code{\link{:}} currently only dispatches at its first argument, thus \code{as.integer64(1):9} works but \code{1:as.integer64(9)} doesn't -#! \code{\link{match}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{match(2, as.integer64(0:3))} -#! \code{\link{\%in\%}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{2 \%in\% as.integer64(0:3)} -#! \code{\link{order}} currently only orders a single argument, trying more than one raises an error -#! } -#! \seealso{ -#! \code{\link{bit64}}, \code{\link{S3}} -#! } -#! \examples{ -#! is.double(as.integer64(1)) -#! as.integer64(1):9 -#! match(as.integer64(2), as.integer64(0:3)) -#! as.integer64(2) \%in\% as.integer64(0:3) -#! -#! unique(as.integer64(c(1,1,2))) -#! rank(as.integer64(c(1,1,2))) -#! -#! %table(as.integer64(c(1,1,2))) -#! %table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))) -#! %table(as.integer64(c(1,1,2)),c(3,4,4)) -#! %table(c(1,1,2),as.integer64(c(3,4,4))) -#! -#! order(as.integer64(c(1,NA,2))) -#! -#! \dontshow{ -#! stopifnot(identical(match(as.integer64(2), as.integer64(0:3)), match(2, 0:3))) -#! stopifnot(identical(as.integer64(2) \%in\% as.integer64(0:3), 2 \%in\% 0:3)) -#! -#! stopifnot(identical(unique(as.integer64(c(1,1,2))), as.integer64(unique(c(1,1,2))))) -#! stopifnot(identical(rank(as.integer64(c(1,1,2))), rank(c(1,1,2)))) -#! -#! %stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2)))) -#! %stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) -#! %stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4)))) -#! %stopifnot(identical(table(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) -#! -#! stopifnot(identical(order(as.integer64(c(1,NA,2))), order(c(1,NA,2)))) -#! stopifnot(identical(order(as.integer64(c(1,NA,2)), decreasing=TRUE), order(c(1,NA,2), decreasing=TRUE))) -#! } -#! } -#! \keyword{ methods } - -# OCT 2013: bit64S3() at wish of CRAN maintainers replaced by direct conversion to S3 generics -# in order to avoid assigning to globalenv - -if (!exists(":.default")){ - ":" <- function(from,to) UseMethod(":") - ":.default" <- function(from,to) base::":"(from,to) -} -":.integer64" <- function(from, to)seq.integer64(from=from, to=to) - -if (!exists("is.double.default")){ - "is.double" <- function(x) UseMethod("is.double") - "is.double.default" <- function(x) base::"is.double"(x) -} -"is.double.integer64" <- function(x)FALSE - -if (!exists("match.default")){ - "match" <- function(x, table, ...) UseMethod("match") - "match.default" <- function(x, table, ...) base::"match"(x, table, ...) -} - -if (!exists("%in%.default")){ - "%in%" <- function(x, table) UseMethod("%in%") - "%in%.default" <- function(x, table) base::"%in%"(x, table) -} - -if (!exists("rank.default")){ - "rank" <- function(x, ...) UseMethod("rank") - "rank.default" <- function(x, ...) base::"rank"(x, ...) -} - -# not yet able to combinewith other column types - better leave table() as is and hope for as.factor.integer64 -#if (!exists("table.default")){ -# "table" <- function(...) UseMethod("table") -# "table.default" <- function(...) base::"table"(...) -#} - -if (!exists("order.default")){ - "order" <- function(...) UseMethod("order") - "order.default" <- function(...) base::"order"(...) -} - +# /* +# R-Code for patching S3 generics +# S3 atomic 64bit integers for R +# (c) 2011 Jens Oehlschägel +# Licence: GPL2 +# Provided 'as is', use at your own risk +# Created: 2011-12-11 +# Last changed: 2011-12-11 +# */ + +#! \name{bit64S3} +#! \alias{bit64S3} +#! \alias{:} +#! \alias{:.default} +#! \alias{:.integer64} +#! \alias{is.double} +#! \alias{is.double.default} +#! \alias{is.double.integer64} +#! \alias{match} +#! \alias{match.default} +#! \alias{\%in\%} +#! \alias{\%in\%.default} +#! \alias{rank} +#! \alias{rank.default} +#! %\alias{table} +#! %\alias{table.default} +#! \alias{order} +#! \alias{order.default} +#! \title{ +#! Turning base R functions into S3 generics for bit64 +#! } +#! \description{ +#! Turn those base functions S3 generic which are used in bit64 +#! } +#! \usage{ +#! from:to +#! #--as-cran complains about \method{:}{default}(from, to) +#! #--as-cran complains about \method{:}{integer64}(from, to) +#! is.double(x) +#! \method{is.double}{default}(x) +#! \method{is.double}{integer64}(x) +#! match(x, table, ...) +#! \method{match}{default}(x, table, ...) +#! x \%in\% table +#! \method{\%in\%}{default}(x, table) +#! rank(x, ...) +#! \method{rank}{default}(x, ...) +#! %table(...) +#! %\method{table}{default}(...) +#! order(...) +#! \method{order}{default}(...) +#! } +#! \arguments{ +#! \item{x}{ +#! integer64 vector: the values to be matched, optionally carrying a cache created with \code{\link{hashcache}} +#! } +#! \item{table}{ +#! integer64 vector: the values to be matched against, optionally carrying a cache created with \code{\link{hashcache}} or \code{\link{sortordercache}} +#! } +#! \item{from}{ scalar denoting first element of sequence } +#! \item{to}{ scalar denoting last element of sequence } +#! \item{\dots}{ ignored } +#! } +#! \details{ +#! The following functions are turned into S3 gernerics in order to dispatch methods for \code{\link{integer64}}: +#! \preformatted{ +#! \code{\link{:}} +#! \code{\link{is.double}} +#! \code{\link{match}} +#! \code{\link{\%in\%}} +#! %\code{\link{table}} +#! \code{\link{rank}} +#! \code{\link{order}} +#! } +#! } +#! \value{ +#! \code{\link{invisible}} +#! } +#! \author{ +#! Jens Oehlschlägel +#! } +#! \note{ +#! \code{\link{is.double}} returns \code{FALSE} for \code{\link{integer64}} \cr +#! \code{\link{:}} currently only dispatches at its first argument, thus \code{as.integer64(1):9} works but \code{1:as.integer64(9)} doesn't +#! \code{\link{match}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{match(2, as.integer64(0:3))} +#! \code{\link{\%in\%}} currently only dispatches at its first argument and expects its second argument also to be integer64, otherwise throws an error. Beware of something like \code{2 \%in\% as.integer64(0:3)} +#! \code{\link{order}} currently only orders a single argument, trying more than one raises an error +#! } +#! \seealso{ +#! \code{\link{bit64}}, \code{\link{S3}} +#! } +#! \examples{ +#! is.double(as.integer64(1)) +#! as.integer64(1):9 +#! match(as.integer64(2), as.integer64(0:3)) +#! as.integer64(2) \%in\% as.integer64(0:3) +#! +#! unique(as.integer64(c(1,1,2))) +#! rank(as.integer64(c(1,1,2))) +#! +#! %table(as.integer64(c(1,1,2))) +#! %table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))) +#! %table(as.integer64(c(1,1,2)),c(3,4,4)) +#! %table(c(1,1,2),as.integer64(c(3,4,4))) +#! +#! order(as.integer64(c(1,NA,2))) +#! +#! \dontshow{ +#! stopifnot(identical(match(as.integer64(2), as.integer64(0:3)), match(2, 0:3))) +#! stopifnot(identical(as.integer64(2) \%in\% as.integer64(0:3), 2 \%in\% 0:3)) +#! +#! stopifnot(identical(unique(as.integer64(c(1,1,2))), as.integer64(unique(c(1,1,2))))) +#! stopifnot(identical(rank(as.integer64(c(1,1,2))), rank(c(1,1,2)))) +#! +#! %stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2)))) +#! %stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) +#! %stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4)))) +#! %stopifnot(identical(table(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4)))) +#! +#! stopifnot(identical(order(as.integer64(c(1,NA,2))), order(c(1,NA,2)))) +#! stopifnot(identical(order(as.integer64(c(1,NA,2)), decreasing=TRUE), order(c(1,NA,2), decreasing=TRUE))) +#! } +#! } +#! \keyword{ methods } + +# OCT 2013: bit64S3() at wish of CRAN maintainers replaced by direct conversion to S3 generics +# in order to avoid assigning to globalenv + +if (!exists(":.default")){ + ":" <- function(from,to) UseMethod(":") + ":.default" <- function(from,to) base::":"(from,to) +} +":.integer64" <- function(from, to)seq.integer64(from=from, to=to) + +if (!exists("is.double.default")){ + "is.double" <- function(x) UseMethod("is.double") + "is.double.default" <- function(x) base::"is.double"(x) +} +"is.double.integer64" <- function(x)FALSE + +if (!exists("match.default")){ + "match" <- function(x, table, ...) UseMethod("match") + "match.default" <- function(x, table, ...) base::"match"(x, table, ...) +} + +if (!exists("%in%.default")){ + "%in%" <- function(x, table) UseMethod("%in%") + "%in%.default" <- function(x, table) base::"%in%"(x, table) +} + +if (!exists("rank.default")){ + "rank" <- function(x, ...) UseMethod("rank") + "rank.default" <- function(x, ...) base::"rank"(x, ...) +} + +# not yet able to combinewith other column types - better leave table() as is and hope for as.factor.integer64 +#if (!exists("table.default")){ +# "table" <- function(...) UseMethod("table") +# "table.default" <- function(...) base::"table"(...) +#} + +if (!exists("order.default")){ + "order" <- function(...) UseMethod("order") + "order.default" <- function(...) base::"order"(...) +} + diff -Nru r-cran-bit64-0.9-7.1/R/sort64.R r-cran-bit64-4.0.5/R/sort64.R --- r-cran-bit64-0.9-7.1/R/sort64.R 2017-05-07 18:05:58.000000000 +0000 +++ r-cran-bit64-4.0.5/R/sort64.R 2020-07-31 16:11:34.000000000 +0000 @@ -91,7 +91,7 @@ #! \item{\dots}{ further arguments, passed from generics, ignored in methods } #! } #! \details{ -#! see \code{\link[bit]{ramsort}} +#! see \code{\link{ramsort}} #! } #! \value{ #! These functions return the number of \code{NAs} found or assumed during sorting @@ -101,7 +101,7 @@ #! } #! \keyword{ programming } #! \keyword{ manip } -#! \seealso{ \code{\link{ramsort}} for the generic, \code{\link[ff]{ramsort.default}} for the methods provided by package \code{\link[ff]{ff}}, \code{\link{sort.integer64}} for the sort interface and \code{\link{sortcache}} for caching the work of sorting} +#! \seealso{ \code{\link{ramsort}} for the generic, \code{ramsort.default} for the methods provided by package \code{ff}, \code{\link{sort.integer64}} for the sort interface and \code{\link{sortcache}} for caching the work of sorting} #! \examples{ #! x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE)) #! x @@ -687,4 +687,3 @@ o } - diff -Nru r-cran-bit64-0.9-7.1/R/sortuse64.R r-cran-bit64-4.0.5/R/sortuse64.R --- r-cran-bit64-0.9-7.1/R/sortuse64.R 2017-05-07 18:05:59.000000000 +0000 +++ r-cran-bit64-4.0.5/R/sortuse64.R 2020-06-14 15:15:59.000000000 +0000 @@ -1,582 +1,563 @@ -# /* -# R-Code for searching and merging -# S3 atomic 64bit integers for R -# (c) 2011 Jens Oehlschägel -# Licence: GPL2 -# Provided 'as is', use at your own risk -# Created: 2011-12-11 -# Last changed: 2011-12-11 -# */ - -#! \name{sortnut} -#! \alias{sortnut} -#! \alias{sortnut.integer64} -#! \alias{ordernut} -#! \alias{ordernut.integer64} -#! \alias{sortfin} -#! \alias{sortfin.integer64} -#! \alias{orderpos} -#! \alias{orderpos.integer64} -#! \alias{orderfin} -#! \alias{orderfin.integer64} -#! \alias{sortorderpos} -#! \alias{sortorderpos.integer64} -#! \alias{orderdup} -#! \alias{orderdup.integer64} -#! \alias{sortorderdup} -#! \alias{sortorderdup.integer64} -#! \alias{sortuni} -#! \alias{sortuni.integer64} -#! \alias{orderuni} -#! \alias{orderuni.integer64} -#! \alias{sortorderuni} -#! \alias{sortorderuni.integer64} -#! \alias{orderupo} -#! \alias{orderupo.integer64} -#! \alias{sortorderupo} -#! \alias{sortorderupo.integer64} -#! \alias{ordertie} -#! \alias{ordertie.integer64} -#! \alias{sortordertie} -#! \alias{sortordertie.integer64} -#! \alias{sorttab} -#! \alias{sorttab.integer64} -#! \alias{ordertab} -#! \alias{ordertab.integer64} -#! \alias{sortordertab} -#! \alias{sortordertab.integer64} -#! \alias{orderkey} -#! \alias{orderkey.integer64} -#! \alias{sortorderkey} -#! \alias{sortorderkey.integer64} -#! \alias{orderrnk} -#! \alias{orderrnk.integer64} -#! \alias{sortorderrnk} -#! \alias{sortorderrnk.integer64} -#! \alias{sortqtl} -#! \alias{sortqtl.integer64} -#! \alias{orderqtl} -#! \alias{orderqtl.integer64} -#! \title{ -#! Searching and other uses of sorting for 64bit integers -#! } -#! \description{ -#! This is roughly an implementation of hash functionality but based on sorting instead on a hasmap. -#! Since sorting is more informative than hashingwe can do some more interesting things. -#! } -#! \usage{ -#! sortnut(sorted, \dots) -#! ordernut(table, order, \dots) -#! sortfin(sorted, x, \dots) -#! orderfin(table, order, x, \dots) -#! orderpos(table, order, x, \dots) -#! sortorderpos(sorted, order, x, \dots) -#! orderdup(table, order, \dots) -#! sortorderdup(sorted, order, \dots) -#! sortuni(sorted, nunique, \dots) -#! orderuni(table, order, nunique, \dots) -#! sortorderuni(table, sorted, order, nunique, \dots) -#! orderupo(table, order, nunique, \dots) -#! sortorderupo(sorted, order, nunique, keep.order = FALSE, \dots) -#! ordertie(table, order, nties, \dots) -#! sortordertie(sorted, order, nties, \dots) -#! sorttab(sorted, nunique, \dots) -#! ordertab(table, order, nunique, \dots) -#! sortordertab(sorted, order, \dots) -#! orderkey(table, order, na.skip.num = 0L, \dots) -#! sortorderkey(sorted, order, na.skip.num = 0L, \dots) -#! orderrnk(table, order, na.count, \dots) -#! sortorderrnk(sorted, order, na.count, \dots) -#! \method{sortnut}{integer64}(sorted, \dots) -#! \method{ordernut}{integer64}(table, order, \dots) -#! \method{sortfin}{integer64}(sorted, x, method=NULL, \dots) -#! \method{orderfin}{integer64}(table, order, x, method=NULL, \dots) -#! \method{orderpos}{integer64}(table, order, x, nomatch=NA, method=NULL, \dots) -#! \method{sortorderpos}{integer64}(sorted, order, x, nomatch=NA, method=NULL, \dots) -#! \method{orderdup}{integer64}(table, order, method=NULL, \dots) -#! \method{sortorderdup}{integer64}(sorted, order, method=NULL, \dots) -#! \method{sortuni}{integer64}(sorted, nunique, \dots) -#! \method{orderuni}{integer64}(table, order, nunique, keep.order=FALSE, \dots) -#! \method{sortorderuni}{integer64}(table, sorted, order, nunique, \dots) -#! \method{orderupo}{integer64}(table, order, nunique, keep.order=FALSE, \dots) -#! \method{sortorderupo}{integer64}(sorted, order, nunique, keep.order = FALSE, \dots) -#! \method{ordertie}{integer64}(table, order, nties, \dots) -#! \method{sortordertie}{integer64}(sorted, order, nties, \dots) -#! \method{sorttab}{integer64}(sorted, nunique, \dots) -#! \method{ordertab}{integer64}(table, order, nunique, denormalize=FALSE, keep.order=FALSE, \dots) -#! \method{sortordertab}{integer64}(sorted, order, denormalize=FALSE, \dots) -#! \method{orderkey}{integer64}(table, order, na.skip.num = 0L, \dots) -#! \method{sortorderkey}{integer64}(sorted, order, na.skip.num = 0L, \dots) -#! \method{orderrnk}{integer64}(table, order, na.count, \dots) -#! \method{sortorderrnk}{integer64}(sorted, order, na.count, \dots) -#! \method{sortqtl}{integer64}(sorted, na.count, probs, \dots) -#! \method{orderqtl}{integer64}(table, order, na.count, probs, \dots) -#! } -#! \arguments{ -#! \item{x}{ an \code{\link{integer64}} vector } -#! \item{sorted}{ a sorted \code{\link{integer64}} vector } -#! \item{table}{ the original data with original order under the sorted vector } -#! \item{order}{ an \code{\link{integer}} order vector that turns 'table' into 'sorted' } -#! \item{nunique}{ number of unique elements, usually we get this from cache or call \code{sortnut} or \code{ordernut} } -#! \item{nties}{ number of tied values, usually we get this from cache or call \code{sortnut} or \code{ordernut} } -#! \item{denormalize}{ FALSE returns counts of unique values, TRUE returns each value with its counts } -#! \item{nomatch}{ the value to be returned if an element is not found in the hashmap } -#! \item{keep.order}{ determines order of results and speed: \code{FALSE} (the default) is faster and returns in sorted order, \code{TRUE} returns in the order of first appearance in the original data, but this requires extra work } -#! \item{probs}{ vector of probabilities in [0..1] for which we seek quantiles } -#! \item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA}, the latter needed for \code{\link{as.factor.integer64}} } -#! \item{na.count}{ the number of \code{NA}s, needed for this low-level function algorithm } -#! \item{method}{ see details } -#! \item{\dots}{ further arguments, passed from generics, ignored in methods } -#! } -#! \details{ -#! \tabular{rrrrl}{ -#! \bold{sortfun} \tab \bold{orderfun} \tab \bold{sortorderfun} \tab \bold{see also} \tab \bold{description} \cr -#! \code{sortnut} \tab \code{ordernut} \tab \tab \tab return number of tied and of unique values \cr -#! \code{sortfin} \tab \code{orderfin} \tab \tab \code{\link{\%in\%.integer64}} \tab return logical whether \code{x} is in \code{table} \cr -#! \tab \code{orderpos} \tab \code{sortorderpos} \tab \code{\link[=match.integer64]{match}} \tab return positions of \code{x} in \code{table} \cr -#! \tab \code{orderdup} \tab \code{sortorderdup} \tab \code{\link[=duplicated.integer64]{duplicated}} \tab return logical whether values are duplicated \cr -#! \code{sortuni} \tab \code{orderuni} \tab \code{sortorderuni} \tab \code{\link[=unique.integer64]{unique}} \tab return unique values (=dimensiontable) \cr -#! \tab \code{orderupo} \tab \code{sortorderupo} \tab \code{\link[=unique.integer64]{unique}} \tab return positions of unique values \cr -#! \tab \code{ordertie} \tab \code{sortordertie} \tab \tab return positions of tied values \cr -#! \tab \code{orderkey} \tab \code{sortorderkey} \tab \tab positions of values in vector of unique values (match in dimensiontable) \cr -#! \code{sorttab} \tab \code{ordertab} \tab \code{sortordertab} \tab \code{\link[=table.integer64]{table}} \tab tabulate frequency of values \cr -#! \tab \code{orderrnk} \tab \code{sortorderrnk} \tab \tab rank averaging ties \cr -#! \code{sortqtl} \tab \code{orderqtl} \tab \tab \tab return quantiles given probabilities \cr -#! } -#! The functions \code{sortfin}, \code{orderfin}, \code{orderpos} and \code{sortorderpos} each offer three algorithms for finding \code{x} in \code{table}. \cr -#! With \code{method=1L} each value of \code{x} is searched independently using \emph{binary search}, this is fastest for small \code{table}s. \cr -#! With \code{method=2L} the values of \code{x} are first sorted and then searched using \emph{doubly exponential search}, this is the best allround method. \cr -#! With \code{method=3L} the values of \code{x} are first sorted and then searched using simple merging, this is the fastest method if \code{table} is huge and \code{x} has similar size and distribution of values. \cr -#! With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr -#! -#! The functions \code{orderdup} and \code{sortorderdup} each offer two algorithms for setting the truth values in the return vector. \cr -#! With \code{method=1L} the return values are set directly which causes random write access on a possibly large return vector. \cr -#! With \code{method=2L} the return values are first set in a smaller bit-vector -- random access limited to a smaller memory region -- and finally written sequentially to the logical output vector. \cr -#! With \code{method=NULL} the functions use a heuristic to determine the fastest algorithm. \cr -#! } -#! \value{ -#! see details -#! } -#! \author{ -#! Jens Oehlschlägel -#! } -#! \keyword{ programming } -#! \keyword{ manip } -#! \seealso{ \code{\link[=match.integer64]{match}} } -#! \examples{ -#! message("check the code of 'optimizer64' for examples:") -#! print(optimizer64) -#! } - - - -sortnut <- function(sorted, ...)UseMethod("sortnut") -sortnut.integer64 <- function(sorted, ...) -{ - ret <- .Call(C_r_ram_integer64_sortnut, x = sorted, PACKAGE = "bit64") - names(ret) <- c("nunique","nties") - ret -} - -ordernut <- function(table, order, ...)UseMethod("ordernut") -ordernut.integer64 <- function(table, order, ...) -{ - ret <- .Call(C_r_ram_integer64_ordernut, table = as.integer64(table), order = as.integer(order), PACKAGE = "bit64") - names(ret) <- c("nunique","nties") - ret -} - -sortfin <- function(sorted, x, ...)UseMethod("sortfin") -sortfin.integer64 <- function(sorted, x, method=NULL, ...) -{ - n <- length(x) - if (is.null(method)){ - if (n<2048){ - method <- 1L - }else if (n +#! } +#! \keyword{ programming } +#! \keyword{ manip } +#! \seealso{ \code{\link[=match.integer64]{match}} } +#! \examples{ +#! message("check the code of 'optimizer64' for examples:") +#! print(optimizer64) +#! } + + + +sortnut <- function(sorted, ...)UseMethod("sortnut") +sortnut.integer64 <- function(sorted, ...) +{ + ret <- .Call(C_r_ram_integer64_sortnut, x = sorted, PACKAGE = "bit64") + names(ret) <- c("nunique","nties") + ret +} + +ordernut <- function(table, order, ...)UseMethod("ordernut") +ordernut.integer64 <- function(table, order, ...) +{ + ret <- .Call(C_r_ram_integer64_ordernut, table = as.integer64(table), order = as.integer(order), PACKAGE = "bit64") + names(ret) <- c("nunique","nties") + ret +} + +sortfin <- function(sorted, x, ...)UseMethod("sortfin") +sortfin.integer64 <- function(sorted, x, method=NULL, ...) +{ + n <- length(x) + if (is.null(method)){ + if (n<2048){ + method <- 1L + }else if (n= >") packageStartupMessage("arithmetic operator: + - * / %/% %% ^") packageStartupMessage("math: sign abs sqrt log log2 log10") diff -Nru r-cran-bit64-0.9-7.1/src/cache.c r-cran-bit64-4.0.5/src/cache.c --- r-cran-bit64-0.9-7.1/src/cache.c 2017-05-07 19:07:42.000000000 +0000 +++ r-cran-bit64-4.0.5/src/cache.c 2020-06-14 15:15:59.000000000 +0000 @@ -1,6 +1,7 @@ #include #include +/* SEXP r_ram_truly_identical( SEXP x_ , SEXP y_ @@ -52,4 +53,4 @@ UNPROTECT(1); return ret_; } - +*/ diff -Nru r-cran-bit64-0.9-7.1/src/hash64.c r-cran-bit64-4.0.5/src/hash64.c --- r-cran-bit64-0.9-7.1/src/hash64.c 2017-05-07 19:07:42.000000000 +0000 +++ r-cran-bit64-4.0.5/src/hash64.c 2020-06-14 15:15:59.000000000 +0000 @@ -55,7 +55,7 @@ } } INTEGER(nunique_)[0] = nunique; - return R_NilValue; + return hashpos_; } SEXP hashpos_integer64(SEXP x_, SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP nomatch_, SEXP ret_){ @@ -87,7 +87,7 @@ } } } - return R_NilValue; + return ret_; } SEXP hashrev_integer64(SEXP x_, SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP nunique_, SEXP nomatch_, SEXP ret_){ @@ -149,7 +149,7 @@ ret[i] = nomatch; } } - return R_NilValue; + return ret_; } SEXP hashrin_integer64(SEXP x_, SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP nunique_, SEXP ret_){ @@ -202,7 +202,7 @@ } } } - return R_NilValue; + return ret_; } SEXP hashfin_integer64(SEXP x_, SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP ret_){ @@ -233,7 +233,7 @@ } } } - return R_NilValue; + return ret_; } SEXP hashdup_integer64(SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP nunique_, SEXP ret_){ @@ -252,7 +252,7 @@ if (nunique<1) break; } - return R_NilValue; + return ret_; } SEXP hashuni_integer64(SEXP hashdat_, SEXP bits_, SEXP hashpos_, SEXP keep_order_, SEXP ret_){ @@ -285,7 +285,7 @@ ret[u++] = hashdat[hashpos[h]-1]; } } - return R_NilValue; + return ret_; } SEXP hashmapuni_integer64(SEXP x_, SEXP bits_, SEXP hashpos_, SEXP nunique_){ @@ -351,7 +351,7 @@ ret[u++] = hashpos[h]; } } - return R_NilValue; + return ret_; } SEXP hashmapupo_integer64(SEXP x_, SEXP bits_, SEXP hashpos_, SEXP nunique_){ diff -Nru r-cran-bit64-0.9-7.1/src/init.c r-cran-bit64-4.0.5/src/init.c --- r-cran-bit64-0.9-7.1/src/init.c 2017-05-07 19:07:42.000000000 +0000 +++ r-cran-bit64-4.0.5/src/init.c 2020-07-31 10:15:10.000000000 +0000 @@ -10,6 +10,7 @@ extern SEXP as_bitstring_integer64(SEXP, SEXP); extern SEXP as_character_integer64(SEXP, SEXP); extern SEXP as_double_integer64(SEXP, SEXP); +extern SEXP as_integer64_bitstring(SEXP, SEXP); extern SEXP as_integer64_character(SEXP, SEXP); extern SEXP as_integer64_double(SEXP, SEXP); extern SEXP as_integer64_integer(SEXP, SEXP); @@ -59,6 +60,7 @@ extern SEXP power_integer64_integer64(SEXP, SEXP, SEXP); extern SEXP prod_integer64(SEXP, SEXP, SEXP); extern SEXP range_integer64(SEXP, SEXP, SEXP); +extern SEXP runif_integer64(SEXP, SEXP, SEXP); extern SEXP r_ram_integer64_issorted_asc(SEXP); extern SEXP r_ram_integer64_mergeorder(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP r_ram_integer64_mergesort(SEXP, SEXP, SEXP, SEXP); @@ -98,13 +100,19 @@ extern SEXP r_ram_integer64_sortsrt(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP r_ram_integer64_sorttab_asc(SEXP, SEXP); extern SEXP r_ram_integer64_sortuni_asc(SEXP, SEXP); -extern SEXP r_ram_truly_identical(SEXP, SEXP); +/* extern SEXP r_ram_truly_identical(SEXP, SEXP); */ extern SEXP seq_integer64(SEXP, SEXP, SEXP); extern SEXP sign_integer64(SEXP, SEXP); extern SEXP sqrt_integer64(SEXP, SEXP); extern SEXP sum_integer64(SEXP, SEXP, SEXP); extern SEXP times_integer64_double(SEXP, SEXP, SEXP); extern SEXP times_integer64_integer64(SEXP, SEXP, SEXP); +/* +extern SEXP r_ram_integer64_radisort(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP r_ram_integer64_onionsort(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP r_ram_integer64_onionsortorder(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP r_ram_integer64_onionorder(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +*/ static const R_CallMethodDef CallEntries[] = { {"abs_integer64", (DL_FUNC) &abs_integer64, 2}, @@ -113,6 +121,7 @@ {"as_bitstring_integer64", (DL_FUNC) &as_bitstring_integer64, 2}, {"as_character_integer64", (DL_FUNC) &as_character_integer64, 2}, {"as_double_integer64", (DL_FUNC) &as_double_integer64, 2}, + {"as_integer64_bitstring", (DL_FUNC) &as_integer64_bitstring, 2}, {"as_integer64_character", (DL_FUNC) &as_integer64_character, 2}, {"as_integer64_double", (DL_FUNC) &as_integer64_double, 2}, {"as_integer64_integer", (DL_FUNC) &as_integer64_integer, 2}, @@ -162,6 +171,7 @@ {"power_integer64_integer64", (DL_FUNC) &power_integer64_integer64, 3}, {"prod_integer64", (DL_FUNC) &prod_integer64, 3}, {"range_integer64", (DL_FUNC) &range_integer64, 3}, + {"runif_integer64", (DL_FUNC) &runif_integer64, 3}, {"r_ram_integer64_issorted_asc", (DL_FUNC) &r_ram_integer64_issorted_asc, 1}, {"r_ram_integer64_mergeorder", (DL_FUNC) &r_ram_integer64_mergeorder, 5}, {"r_ram_integer64_mergesort", (DL_FUNC) &r_ram_integer64_mergesort, 4}, @@ -201,16 +211,23 @@ {"r_ram_integer64_sortsrt", (DL_FUNC) &r_ram_integer64_sortsrt, 5}, {"r_ram_integer64_sorttab_asc", (DL_FUNC) &r_ram_integer64_sorttab_asc, 2}, {"r_ram_integer64_sortuni_asc", (DL_FUNC) &r_ram_integer64_sortuni_asc, 2}, - {"r_ram_truly_identical", (DL_FUNC) &r_ram_truly_identical, 2}, +/* {"r_ram_truly_identical", (DL_FUNC) &r_ram_truly_identical, 2},*/ {"seq_integer64", (DL_FUNC) &seq_integer64, 3}, {"sign_integer64", (DL_FUNC) &sign_integer64, 2}, {"sqrt_integer64", (DL_FUNC) &sqrt_integer64, 2}, {"sum_integer64", (DL_FUNC) &sum_integer64, 3}, {"times_integer64_double", (DL_FUNC) ×_integer64_double, 3}, {"times_integer64_integer64", (DL_FUNC) ×_integer64_integer64, 3}, +/* + {"r_ram_integer64_radisort", (DL_FUNC) &r_ram_integer64_radisort, 5}, + {"r_ram_integer64_onionsort", (DL_FUNC) &r_ram_integer64_onionsort, 7}, + {"r_ram_integer64_onionsortorder", (DL_FUNC) &r_ram_integer64_onionsortorder, 8}, + {"r_ram_integer64_onionorder", (DL_FUNC) &r_ram_integer64_onionorder, 8}, +*/ {NULL, NULL, 0} }; + void R_init_bit64(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); diff -Nru r-cran-bit64-0.9-7.1/src/integer64.c r-cran-bit64-4.0.5/src/integer64.c --- r-cran-bit64-0.9-7.1/src/integer64.c 2017-05-07 19:07:42.000000000 +0000 +++ r-cran-bit64-4.0.5/src/integer64.c 2020-08-14 17:36:35.000000000 +0000 @@ -50,6 +50,11 @@ /** **/ /*****************************************************************************/ +typedef struct Unsigned32x2TStruct { + unsigned int low; + unsigned int high; +} Unsigned32x2T; + /*****************************************************************************/ /** **/ /** PROTOTYPYPES OF LOCAL FUNCTIONS **/ @@ -205,7 +210,7 @@ } SEXP as_bitstring_integer64(SEXP x_, SEXP ret_){ - long long i, n = LENGTH(ret_); + int i, n = LENGTH(ret_); long long * x = (long long *) REAL(x_); unsigned long long mask; long long v; @@ -225,11 +230,44 @@ } *str = 0; SET_STRING_ELT(ret_, i, mkChar(buff)); + R_CheckUserInterrupt(); + } + return ret_; +} + +SEXP as_integer64_bitstring(SEXP x_, SEXP ret_){ + Rboolean naflag = FALSE; + int i, k, l, n = LENGTH(x_); + long long * ret = (long long *) REAL(ret_); + unsigned long long mask; + long long v; + const char * str; + for(i=0; iBITS_INTEGER64){ + ret[i] = NA_INTEGER64; + naflag = TRUE; + break; + } + mask = 1; + v = 0; + for (k=l-1; k>=0; k--){ + if (str[k] != '0' && str[k] != ' '){ + v |= mask; + } + mask <<= 1; + } + ret[i] = v; + R_CheckUserInterrupt(); } + if (naflag)warning(BITSTRING_OVERFLOW_WARNING); return ret_; } -SEXP plus_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ + + +__attribute__((no_sanitize("signed-integer-overflow"))) SEXP plus_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ long long i, n = LENGTH(ret_); long long i1, n1 = LENGTH(e1_); long long i2, n2 = LENGTH(e2_); @@ -244,7 +282,7 @@ return ret_; } -SEXP minus_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ +__attribute__((no_sanitize("signed-integer-overflow"))) SEXP minus_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ long long i, n = LENGTH(ret_); long long i1, n1 = LENGTH(e1_); long long i2, n2 = LENGTH(e2_); @@ -259,7 +297,7 @@ return ret_; } -SEXP diff_integer64(SEXP x_, SEXP lag_, SEXP n_, SEXP ret_){ +__attribute__((no_sanitize("signed-integer-overflow"))) SEXP diff_integer64(SEXP x_, SEXP lag_, SEXP n_, SEXP ret_){ long long i, n = *((long long *) REAL(n_)); long long * x = (long long *) REAL(x_); long long * lag = (long long *) REAL(lag_); @@ -306,7 +344,7 @@ } -SEXP times_integer64_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ +__attribute__((no_sanitize("signed-integer-overflow"))) SEXP times_integer64_integer64(SEXP e1_, SEXP e2_, SEXP ret_){ long long i, n = LENGTH(ret_); long long i1, n1 = LENGTH(e1_); long long i2, n2 = LENGTH(e2_); @@ -936,6 +974,56 @@ return ret_; } +SEXP runif_integer64(SEXP n_, SEXP min_, SEXP max_){ + int i, n=asInteger(n_); + long long min = *((long long * ) REAL(min_)); + long long max = *((long long * ) REAL(max_)); + unsigned long long d; + // max - min can overflow + if (min < 0 && max > 0){ + d = ((unsigned long long)(-min)) + ((unsigned long long)max) + 1; + }else{ + d = (max - min) + 1; + } + SEXP ret_; + PROTECT(ret_ = allocVector(REALSXP, n)); + long long * ret = (long long *) REAL(ret_); + Unsigned32x2T ii; + GetRNGstate(); + for (i=0; i= n); + while((r = ((IndexT)(unif_rand()*n))) >= n){} + ; PutRNGstate(); return r; } @@ -2138,9 +2139,9 @@ IndexT **pstats; pstats = (IndexT **) R_alloc(nradixes, sizeof(IndexT*)); - for (i=0;i