Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:a4c99a50dc49f82b591f268001b320f8c3ca0041
  • Code
  • Branches (42)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.96
    • refs/tags/0.97-1
    • refs/tags/1.0-1
    • refs/tags/1.0-2
    • refs/tags/1.0-3
    • refs/tags/1.0-4
    • refs/tags/1.0-5
    • refs/tags/1.0-6
    • refs/tags/1.0-6.1
    • refs/tags/R-2.10.0
    • refs/tags/R-2.10.1
    • refs/tags/R-2.11.0
    • refs/tags/R-2.11.1
    • refs/tags/R-2.12.0
    • refs/tags/R-2.12.1
    • refs/tags/R-2.12.2
    • refs/tags/R-2.13.0
    • refs/tags/R-2.13.1
    • refs/tags/R-2.13.2
    • refs/tags/R-2.14.0
    • refs/tags/R-2.14.1
    • refs/tags/R-2.14.2
    • refs/tags/R-2.15.0
    • refs/tags/R-2.15.1
    • refs/tags/R-2.15.2
    • refs/tags/R-2.15.3
    • refs/tags/R-2.6.0
    • refs/tags/R-2.6.1
    • refs/tags/R-2.6.2
    • refs/tags/R-2.7.0
    • refs/tags/R-2.7.1
    • refs/tags/R-2.7.2
    • refs/tags/R-2.8.0
    • refs/tags/R-2.8.1
    • refs/tags/R-2.9.0
    • refs/tags/R-2.9.1
    • refs/tags/R-2.9.2
    • refs/tags/R-3.0.0
    • refs/tags/R-3.0.1
    • refs/tags/R-3.0.2
    • refs/tags/R-3.0.3
    No releases to show
  • ed95bb7
  • /
  • R
  • /
  • binaryRepAux.R
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge Iframe embedding
swh:1:cnt:72b679907c471a73e7321cb7c66c322919be3bd8
directory badge Iframe embedding
swh:1:dir:087a74cda8a3a88b1e44c5097c2d8ac2210e805a
revision badge
swh:1:rev:698183c35adc80e5e08cb2ef09ed13dc3c445a97
snapshot badge
swh:1:snp:a4c99a50dc49f82b591f268001b320f8c3ca0041
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 698183c35adc80e5e08cb2ef09ed13dc3c445a97 authored by John M Chambers on 12 June 2014, 00:00:00 UTC
version 1.0-6
Tip revision: 698183c
binaryRepAux.R
## everything for binaryRep except the function itself
setClass("binaryRep",
         representation( original = "numeric",
                        sign = "integer",
               exponent = "integer",
               bits = "raw"))

setMethod("show", "binaryRep",
          function(object){
              cat("Object of class \"", class(object), "\"\n", sep="")
              sign <- ifelse(object@sign < 0, "-", " ")
              pasteBits <- function(bits)
                paste(ifelse(bits>0, "1","0"),collapse="")
              origSep <- "\n      " # could be " " if options()$width large
              bits <- matrix(object@bits, nrow = length(sign))
              bits <- apply(bits, 1, pasteBits)
              lines <- paste(format(1:length(sign)),": ",sign,".",
                             bits, " * 2^", object@exponent, origSep,
                             "(", object@original, ")", sep="")
              cat(lines, sep="\n")
          })

binaryRepA <- function(m)
    matrix(rep(c(1, rep(0, m-1), -1), length=m*m), m, m)

binaryRepPowers <- function(n, m)
    (matrix(2 ^ (1:m), 1, m, byrow=TRUE))[rep(1,n),]

binaryRepBits <- function(data) {
    data <- as.vector(data) # throw away matrix structure
    if(any((data%%1)^2 > .Machine$double.eps))
        stop("The \"bits\" have fractional parts.")
    data <- round(data)
    if(!identical(sort(unique(data)), c(0,1)))
        stop("The \"bits\" must be 0 or 1.")
    as.raw(data)
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API