quadform

Quadratic forms in R

https://github.com/robinhankin/quadform

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Quadratic forms in R

Basic Info
  • Host: GitHub
  • Owner: RobinHankin
  • Language: R
  • Default Branch: master
  • Size: 155 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Created about 2 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog

README.Rmd

---
title: "Quadratic forms in R: the `quadform` package"
output: github_document
---



```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# 


[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/quadform)](https://cran.r-project.org/package=quadform)



Quadratic forms are polynomials with all terms of degree 2.  Given a
column vector ${\mathbf x}=(x_1,\ldots,x_n)^\top$ and an $n\times n$
matrix $M$ then the function
$f\colon\mathbb{R}^n\longrightarrow\mathbb{R}$ given by $f({\mathbf
x})=x^TMx$ is a quadratic form; we extend to complex vectors by
mapping ${\mathbf z}=(z_1,\ldots, z_n)^\top$ to ${\mathbf
z}^*M{\mathbf z}$, where $z^*$ means the complex conjugate of $z^T$.
These are implemented in the package with `quad.form(M,x)` which is
essentially

`quad.form <- function(M,x){crossprod(crossprod(M, Conj(x)), x)}.`

This is preferable to `t(x) %*% M %*% x` on several grounds.  Firstly,
it streamlines and simplifies code; secondly, it is more efficient;
and thirdly it handles the complex case consistently.  The package
includes similar functionality for other related expressions.

The main motivation for the package is nicer code.  For example, the
`emulator` package has to manipulate the following expression:

\[
\left[H_x-H^\top A^{-1}U\right]^\top
\left[H^\top\left(H^\top A^{-1}H\right)^{-1}H\right]
\left[H_x-H^\top A^{-1}U\right].
\]

Direct R idiom would be:

```
t(Hx - t(H) %*% solve(A) %*% U) %*%  t(H) %*% solve(t(H) %*% solve(A) %*% H) %*% H %*%  (Hx - t(H) %*% solve(A) %*% U)
```

But `quadform` idiom is:

```
quad.form(quad.form.inv(quad.form.inv(A,H),H), Hx - quad3.form.inv(A,H,U))
```

and in terse form becomes:

```
qf(qfi(qfi(A,H),H), Hx - q3fi(A,H,U))
```


which is certainly shorter, arguably more elegant, and possibly faster.

The package is maintained on
[github](https://github.com/RobinHankin/quadform).

Owner

  • Name: Robin Hankin
  • Login: RobinHankin
  • Kind: user
  • Location: Auckland
  • Company: AUT

pushing the boundaries of R in non-statistical contexts

GitHub Events

Total
  • Push event: 3
Last Year
  • Push event: 3

Packages

  • Total packages: 1
  • Total downloads:
    • cran 229 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: quadform

Efficient Evaluation of Quadratic Forms

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 229 Last month
Rankings
Dependent packages count: 28.0%
Dependent repos count: 36.0%
Average: 49.7%
Downloads: 85.1%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.0.1 depends
  • mathjaxr * imports
  • testthat * suggests