Skip to content

Commit

Permalink
\cdot no longer hard-coded, including in showEqn(); moved R/dot.R to …
Browse files Browse the repository at this point in the history
…dev/dot.R
  • Loading branch information
john-d-fox committed Aug 27, 2024
1 parent 1f5e692 commit 988779d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 169 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export(circle3d)
export(cofactor)
export(cone3d)
export(corner)
export(dot)
export(echelon)
export(gaussianElimination)
export(getBody)
Expand Down
107 changes: 0 additions & 107 deletions R/dot.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/latexMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ as.double.latexMatrix <- function(x, locals=list(), ...){

X <- getBody(x)
nrow <- nrow(X)
X <- gsub("\\\\cdot", "\\*", X)
X <- gsub(paste0("\\\\", getLatexMultSymbol()), "*", X)
X <- gsub("\\}", ")",
gsub("\\}\\{", ")/(",
gsub("\\\\[cdt]?frac\\{", "(", X)))
Expand Down
2 changes: 0 additions & 2 deletions R/latexMatrixOperations.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@
#' X <- latexMatrix(matrix(c(3, 2, 0, 1, 1, 1, 2,-2, 1), 3, 3))
#' X
#' as.numeric(X)
#' \dontrun{
#' MASS::fractions(as.numeric(inverse(X)))
#' (d <- determinant(X))
#' eval(parse(text=(gsub("\\\\cdot", "*", d))))
#' }
#' X <- latexMatrix(matrix(1:6, 2, 3), matrix="bmatrix")
#' I3 <- latexMatrix(diag(3))
#' I3 %X% X
Expand Down
2 changes: 1 addition & 1 deletion R/showEqn.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ showEqn <- function(A, b, vars, simplify=FALSE, reduce = FALSE,
}
if(latex){
res <- gsub('x', 'x_', res)
res <- gsub('\\*', ' \\\\cdot ', res)
res <- gsub('\\*', paste0(' \\\\', getLatexMultSymbol(), ' '), res)
res <- gsub(' \\+ ', ' &+& ', res)
res <- gsub(' \\- ', ' &-& ', res)
res <- gsub(' \\= ', ' &=& ', res)
Expand Down
23 changes: 20 additions & 3 deletions dev/dot.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#' The result of matrix multiplication, \eqn{\mathbf{C} = \mathbf{A} \: \mathbf{B}}
#' is composed of the vector dot products of each \emph{row} of \eqn{\mathbf{A}} with
#' each \emph{column} of \eqn{\mathbf{B}},
#' \deqn{c_{ij} = \mathbf{a}_i^top \mathbf{b}_j
#' \deqn{c_{ij} = \mathbf{a}_i^\top \; \mathbf{b}_j
#' = \Sigma_k a_{ik} \cdot b_{kj}}
#'
#' This function computes this product symbolically in LaTeX notation for
#' numeric and character vectors, simplifying the result if \code{simplify = TRUE.}
#' numeric and character vectors, simplifying the result if \code{simplify = TRUE}.

#' The LaTeX symbol for multiplication (\code{"\\cdot"} by default)
#' can be changed by changing \code{options(latexMultSymbol)},
Expand All @@ -22,7 +22,24 @@
#' \code{-1, 0, 1} are simplified
#' @returns A character string containing the LaTeX expression
#' @export

#' @examples
#' num <- -1:2
#' chr <- letters[1:4]
#'
#' dot(num, num)
#' dot(num, chr)
#' dot(chr, num)
#' dot(chr, chr)
#'
#' dot(num, num, simplify = FALSE)
#' dot(num, chr, simplify = FALSE)
#' dot(chr, num, simplify = FALSE)
#' dot(chr, chr, simplify = FALSE)
#'
#' # change the multpliicatin symbol
#' opt <- options(latexMultSymbol = "\\times")
#' dot(num, chr)
#' dot(chr, chr)

dot <- function(x, y, simplify = TRUE) {
if (length(x) != length(y)) stop("Vectors must have the same length")
Expand Down
52 changes: 0 additions & 52 deletions man/dot.Rd

This file was deleted.

2 changes: 0 additions & 2 deletions man/latexMatrixOperations.Rd

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

0 comments on commit 988779d

Please sign in to comment.