-
Notifications
You must be signed in to change notification settings - Fork 12
Add matrix, array and matrix multiplication for integer64 #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
refactor str.integer64 for consistent display of matrices refactor colSums and rowSums to be consistent to base
R/integer64.R
Outdated
| } else if (!is.null(dim(object))) { | ||
| dimO = dim(object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } else if (!is.null(dim(object))) { | |
| dimO = dim(object) | |
| } else if (!is.null(dimO <- dim(object))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But didn't you want to use = instead of <- consistently?
|
|
||
|
|
||
| # helper for determining the target class for Ops methods | ||
| target_class_for_Ops = function(e1, e2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for this to be a chooseOpsMethod() method?
https://stat.ethz.ch/R-manual/R-devel/library/base/html/chooseOpsMethod.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my knowledge, we can use chooseOpsMethod() to achieve that Date+integer64 and integer64+Date is handled by +.integer64.
Default behaviour: Since both operands have a class attribute, the operation is performed with the warning Incompatible methods ("+.Date", "+.integer64") for "+" and we get a Date or integer64, depending on the first argument. In case of numeric+integer64 this is not necessary, because numeric has no class attribute and therefore +.integer64 is applied.
If we define chooseOpsMethod.integer64 <- function(x,y,mx,my,cl,rev) TRUE, Date+integer64 and integer64+Date are handled by +.integer64. This should also apply to all other methods of the Group "Ops", i.e. +, &, == etc, but not %*% or log.
My helper target_class_for_Ops does not address the method selection. It shall determine the desired output class of the result. In the above example it should be that Date+integer64 and integer64+Date both result in Date and not integer64, if that is added in the function. Right now only complex is assumed to be converted to. In all other cases it is converted to integer64.
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
try fix tests for ubuntu latest
|
Are you fixing the follwing error in the checks for |
This pull request adds support for
matrix,arrayand%*%forinteger64. Since there are no S3 methods formatrixandarray, they are added.In
matrixandarraythe base functions are used. In order to display convinient warnings and errors that show the call (e.g.matrix(1:10, nrow=5)instead ofbase::matrix(...)) I usewithCallingHandlers(). If there is a generic call, this is displayed, and if not, the S3-method call is displayed.In order to display matrices and arrays consistently to R,
str.integer64is changed accordingly.colSums.integer64androwSums.integer64are refactored to throw R consistent error messages.as.matrix.integer64is added to coerce accordingly.Since
aperm.integer64isn't exported, one has to use the generic. Thus it is refactored to useNextMethod().The matrix multiplication uses a new helper function
target_class_for_Ops(), which determines the class of the result. If a matrix multiplication ofinteger64andcomplexis performed, I expect the result incomplex. It also throws R consistent error messages for Ops. This helper is also intended to be used for other Ops methods like*.integer64in the future. The remaining method checks the matrix dimensions and performs the calculation.Closes #45