Skip to content

Commit

Permalink
+ docs for time_evol.R, avg_evol.R, matrices.R
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormarquesr committed Sep 11, 2023
1 parent c31b4dc commit 9aa05b3
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 103 deletions.
42 changes: 19 additions & 23 deletions R/avg_evolution.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Get the Average Mixing Matrix of a Quantum Walk
#' The Average Mixing Matrix of a Quantum Walk
#'
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
Expand All @@ -10,25 +10,22 @@
avg_matrix <- function(object, ...) UseMethod("avg_matrix")


#' Get the Average Mixing Matrix of a Continuous-Time Quantum Walk
#' The Average Mixing Matrix of a Continuous-Time Quantum Walk
#'
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
#'
#' @returns The average mixing matrix of the continuous-time quantum walk.
#'
#' Let \eqn{M(t)} be the mixing matrix of the quantum walk, then the
#' average mixing matrix is defined as
#' @details Let \eqn{M(t)} be the mixing matrix of the quantum walk, then the average mixing matrix is defined as
#'
#' \deqn{\widehat{M} := \lim_{T \to \infty} \frac{1}{T}\int_{0}^T M(t)\textrm{d}t}
#'
#' and encodes the long-term average behavior of the walk. It is possible to prove that
#' and encodes the long-term average behavior of the walk. Given the Hamiltonian
#' \eqn{H = \sum_r \lambda_r E_r}, it is possible to prove that
#'
#' \deqn{\widehat{M} = \sum_r E_r \circ E_r}
#'
#' in which \eqn{E_r} is the orthogonal projector onto the \eqn{\lambda_r}-eigenspace.
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
#'
#' `avg_matrix` returns the matrix from the above calculation.
#' @returns `avg_matrix()` returns the average mixing matrix
#' as a square matrix of the same order as the walk.
#'
#' @export
#'
Expand All @@ -48,7 +45,7 @@ avg_matrix.ctqwalk <- function(object, ...){
return (M)
}

#' Get the Generalized Average Mixing Matrix of a Quantum Walk
#' The Generalized Average Mixing Matrix of a Quantum Walk
#'
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
Expand All @@ -60,21 +57,20 @@ avg_matrix.ctqwalk <- function(object, ...){
gavg_matrix <- function(object, ...) UseMethod("gavg_matrix")


#' Get the Generalized Average Mixing Matrix of a Continuous-Time Quantum Walk
#' The Generalized Average Mixing Matrix of a Continuous-Time Quantum Walk
#'
#' @details Let \eqn{M(t)} be the mixing matrix of the quantum walk and \eqn{R} a random variable
#' with associated probability density function \eqn{f_R(t)}. Then the generalized average mixing
#' matrix under \eqn{R} is defined as
#'
#' \deqn{\widehat{M}_R := \mathbb{E}[M(R)] = \int_{-\infty}^{\infty} M(t)f_R(t)\textrm{d}t}
#'
#' @param object a representation of the quantum walk.
#' @param R samples from the random variable \eqn{R} (For performance, it is recommended at most 10000 samples).
#' @param ... further arguments passed to or from other methods.
#'
#' @returns The generalized average mixing matrix of the continuous-time quantum walk.
#'
#' Let \eqn{M(t)} be the mixing matrix of the quantum walk and \eqn{f_R(t)} the probability
#' density function associated with \eqn{R}, then the generalized average mixing matrix under \eqn{R}
#' is defined as
#'
#' \deqn{\widehat{M}_R := \mathbb{E}[M(R)] = \int_{-\infty}^{\infty} M(t)f_R(t)\textrm{d}t}
#'
#' `gavg_matrix` returns an approximation of the above matrix by the Monte Carlo approach.
#' @returns `gavg_matrix()` returns the generalized average mixing matrix
#' as a square matrix of the same order as the walk.
#'
#' @export
#'
Expand Down
8 changes: 6 additions & 2 deletions R/matrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#'
#' @export
#'
#' @seealso [qwalkr::tr()], [qwalkr::trdot()], [qwalkr::cartesian()]
#'
#' @examples
#' # Return the all-ones matrix of order 5.
#' J(5)
Expand All @@ -29,6 +31,7 @@ J <- function(n){
#' then \eqn{tr(A) = \sum_{i=1}^{n}a_{ii}}.
#'
#' @export
#' @seealso [qwalkr::J()], [qwalkr::trdot()], [qwalkr::cartesian()]
#'
#' @examples
#' A <- rbind(1:5, 2:6, 3:7)
Expand All @@ -51,12 +54,13 @@ tr <- function(A){
#'
#' \deqn{\langle A, B \rangle := tr(A^*B)}
#' @export
#' @seealso [qwalkr::J()], [qwalkr::tr()], [qwalkr::cartesian()]
#'
#' @examples
#' A <- rbind(1:5, 2:6, 3:7)
#' B <- rbind(7:11, 8:12, 9:13)
#'
#' # Calculate the trace inner product of A and B
#' # Compute the trace inner product of A and B
#' trdot(A, B)
trdot <- function(A, B){
return (tr(Conj(t(A)) %*% B))
Expand All @@ -80,6 +84,7 @@ trdot <- function(A, B){
#' \deqn{A(G \times H) = A(G) \otimes I_{m\ x\ m} + I_{n\ x\ n} \otimes A(H)}
#'
#' @export
#' @seealso [qwalkr::J()], [qwalkr::tr()], [qwalkr::trdot()]
#'
#' @examples
#' P3 <- matrix(c(0,1,0,1,0,1,0,1,0), nrow=3)
Expand All @@ -103,4 +108,3 @@ cartesian <- function(G, H=NULL){
}



43 changes: 19 additions & 24 deletions R/time_evolution.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#' Get the Unitary Time Evolution Operator of a Quantum Walk
#' The Unitary Time Evolution Operator of a Quantum Walk
#'
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
Expand All @@ -12,16 +12,9 @@
unitary_matrix <- function(object, ...) UseMethod("unitary_matrix")


#' Get the Unitary Time Evolution Operator of a Continuous-Time Quantum Walk
#' The Unitary Time Evolution Operator of a Continuous-Time Quantum Walk
#'
#' @param object an instance of class `ctqwalk`.
#' @param t it will be returned the evolution operator at time `t`.
#' @param ... further arguments passed to or from other methods.
#'
#' @returns The unitary time evolution operator of the continuous-time quantum walk
#' at time `t`.
#'
#' If \eqn{|\psi(t) \rangle} is the quantum state of the system at time \eqn{t}, and
#' @details If \eqn{|\psi(t) \rangle} is the quantum state of the system at time \eqn{t}, and
#' \eqn{H} the Hamiltonian operator, then the evolution is governed by
#' the Schrodinger equation
#'
Expand All @@ -38,8 +31,12 @@ unitary_matrix <- function(object, ...) UseMethod("unitary_matrix")
#'
#' in which \eqn{H = \sum_r \lambda_r E_r}.
#'
#' `unitary_matrix` returns the result of the above calculation for a
#' provided `t`.
#' @param object an instance of class `ctqwalk`.
#' @param t it will be returned the evolution operator at time `t`.
#' @param ... further arguments passed to or from other methods.
#'
#' @returns `unitary_matrix()` returns the unitary time evolution operator of the
#' CTQW evaluated at time `t`.
#'
#' @export
#' @seealso [qwalkr::ctqwalk()], [qwalkr::unitary_matrix()],
Expand All @@ -56,7 +53,7 @@ unitary_matrix.ctqwalk <- function(object, t, ...){
return (Ut)
}

#' Get the Mixing Matrix of a Quantum Walk
#' The Mixing Matrix of a Quantum Walk
#'
#' @param object a representation of the quantum walk.
#' @param ... further arguments passed to or from other methods.
Expand All @@ -69,16 +66,10 @@ unitary_matrix.ctqwalk <- function(object, t, ...){
mixing_matrix <- function(object, ...) UseMethod("mixing_matrix")


#' Get the Mixing Matrix of a Continuous-Time Quantum Walk
#' The Mixing Matrix of a Continuous-Time Quantum Walk
#'
#' @param object an instance of class `ctqwalk`.
#' @param t it will be returned the mixing matrix at time `t`.
#' @param ... further arguments passed to or from other methods.
#'
#' @returns The mixing matrix of the continuous-time quantum walk.
#'
#' Let \eqn{U(t)} be the time evolution operator of the
#' quantum walk at time \eqn{t}, then the mixing matrix is given by
#' @details Let \eqn{U(t)} be the time evolution operator of the quantum walk at
#' time \eqn{t}, then the mixing matrix is given by
#'
#' \deqn{M(t) = U(t) \circ \overline{U(t)}}
#'
Expand All @@ -89,8 +80,12 @@ mixing_matrix <- function(object, ...) UseMethod("mixing_matrix")
#' of measuring the standard basis state \eqn{|b \rangle} at time \eqn{t}, given that
#' the quantum walk started at \eqn{|a \rangle}.
#'
#' `mixing_matrix` returns the result of the above calculations for a
#' provided `t`.
#' @param object an instance of class `ctqwalk`.
#' @param t it will be returned the mixing matrix at time `t`.
#' @param ... further arguments passed to or from other methods.
#'
#' @returns `mixing_matrix()` returns the mixing matrix of the CTQW
#' evaluated at time `t`.
#'
#' @export
#' @seealso [qwalkr::ctqwalk()], [qwalkr::mixing_matrix()]
Expand Down
3 changes: 3 additions & 0 deletions man/J.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/avg_matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions man/avg_matrix.ctqwalk.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/cartesian.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/gavg_matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions man/gavg_matrix.ctqwalk.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mixing_matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9aa05b3

Please sign in to comment.