-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dot-test.R; edit vignette; bump pkg v0.9.91
- Loading branch information
Showing
3 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ Package: matlib | |
Type: Package | ||
Title: Matrix Functions for Teaching and Learning Linear Algebra and | ||
Multivariate Statistics | ||
Version: 0.9.9 | ||
Date: 2024-07-30 | ||
Version: 0.9.91 | ||
Date: 2024-08-24 | ||
Authors@R: c(person(given = "Michael", family = "Friendly", | ||
role=c("aut", "cre"), email="[email protected]", | ||
comment=c(ORCID="0000-0002-3237-0941")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Test using dot() for matrix mult | ||
|
||
numericDimensions <- matlib:::numericDimensions | ||
updateWrapper <- matlib:::updateWrapper | ||
parenthesize <- matlib:::parenthesize | ||
|
||
`%*%.latexMatrix` <- function(x, y){ | ||
if (!inherits(y, "latexMatrix")){ | ||
stop(deparse(substitute(y)), | ||
" is not of class 'latexMatrix'") | ||
} | ||
numericDimensions(x) | ||
numericDimensions(y) | ||
X <- getBody(x) | ||
Y <- getBody(y) | ||
dimX <- dim(X) | ||
dimY <- dim(Y) | ||
if (dimX[2] != dimY[1]){ | ||
stop('matricies are not conformable for multiplication') | ||
} | ||
|
||
Z <- matrix("", nrow(X), ncol(Y)) | ||
for (i in 1:nrow(X)){ | ||
for (j in 1:ncol(Y)){ | ||
for (k in 1:ncol(X)){ | ||
Z[i, j] <- dot(X[i, ], Y[, j]) | ||
} | ||
} | ||
} | ||
result <- latexMatrix(Z) | ||
result <- updateWrapper(result, getWrapper(x)) | ||
result$dim <- dim(Z) | ||
result | ||
} | ||
|
||
if(FALSE) { | ||
(A <- latexMatrix(matrix(c(1, -3, 0, 1), 2, 2))) | ||
(B <- latexMatrix(matrix(c(5, 3, -1, 4), 2, 2))) | ||
(C <- latexMatrix(symbol="c", 2, 2)) | ||
(D <- latexMatrix(symbol="d", 2, 2)) | ||
|
||
A %*% B | ||
|
||
as.double(A) | ||
as.double(B) | ||
as.double(A) %*% as.double(B) | ||
|
||
A %*% C | ||
A %*% (B - C) | ||
A %*% -B | ||
(A - 2*D) %*% B | ||
|
||
A %*% solve(B) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters