-
Notifications
You must be signed in to change notification settings - Fork 1
[Ready for review] Refactor polymorphism #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
105d2ee
started refactoring polymorphism
dance858 43f51b8
started refactoring polymorphism
dance858 af8da7d
removed CSR_work from expr
dance858 5527b17
refactor hstack to precompute sparsity pattern + new init_expr to reu…
dance858 618efc2
refactored to remove some redundant init functions
dance858 2ed525b
refactor of affine atoms done
dance858 891f127
refactored elementwise univariate to resuse already computed values
dance858 7062b8f
removed COO
dance858 f8f3fdc
finished cleaning up elementwise univariate and affine atoms
dance858 3a23c26
added comment
dance858 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| 1. power should be double | ||
| 2. can we reuse calculations, like in hessian of logistic | ||
| 3. more tests for chain rule elementwise univariate hessian | ||
| 4. in the refactor, add consts | ||
| 5. multiply with one constant vector/scalar argument | ||
| 6. AX where X is a matrix. Can that happen? How is that canonicalized? Maybe it can't happen. | ||
| 6. AX where X is a matrix. Can that happen? How is that canonicalized? Maybe it can't happen. | ||
| 7. Must be able to compute jacobian and hessian of A @ phi(x), so linear operator needs other code! This requires new infrastructure, I think. | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,51 @@ | ||
| #ifndef SUBEXPR_H | ||
| #define SUBEXPR_H | ||
|
|
||
| #include "expr.h" | ||
| #include "utils/CSC_Matrix.h" | ||
| #include "utils/CSR_Matrix.h" | ||
|
|
||
| /* Forward declaration */ | ||
| struct int_double_pair; | ||
|
|
||
| /* Type-specific expression structures that "inherit" from expr */ | ||
|
|
||
| /* Linear operator: y = A * x */ | ||
| typedef struct linear_op_expr | ||
| { | ||
| expr base; | ||
| CSC_Matrix *A_csc; | ||
| CSR_Matrix *A_csr; | ||
| } linear_op_expr; | ||
|
|
||
| /* Power: y = x^p */ | ||
| typedef struct power_expr | ||
| { | ||
| expr base; | ||
| double p; | ||
| } power_expr; | ||
|
|
||
| /* Quadratic form: y = x'*Q*x */ | ||
| typedef struct quad_form_expr | ||
| { | ||
| expr base; | ||
| CSR_Matrix *Q; | ||
| } quad_form_expr; | ||
|
|
||
| /* Sum reduction along an axis */ | ||
| typedef struct sum_expr | ||
| { | ||
| expr base; | ||
| int axis; | ||
| struct int_double_pair *int_double_pairs; /* for sorting jacobian entries */ | ||
| } sum_expr; | ||
|
|
||
| /* Horizontal stack (concatenate) */ | ||
| typedef struct hstack_expr | ||
| { | ||
| expr base; | ||
| expr **args; | ||
| int n_args; | ||
| } hstack_expr; | ||
|
|
||
| #endif /* SUBEXPR_H */ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 this done? Did you mean to add the type hints (I am not sure if that's what we call them) for the arguments to functions?
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 changed from "int p" to "double p" in power_expr, so now it's the correct data type