-
Notifications
You must be signed in to change notification settings - Fork 245
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
Sparse3 #1845
Open
kartikv
wants to merge
64
commits into
flintlib:main
Choose a base branch
from
kartikv:sparse3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sparse3 #1845
Changes from 60 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
57912d7
API for sparse vectors
52d7fbe
adding gr_sparse_vec dir
75d157b
adding fit, set, update
5dd99b0
working on sparse vec
45f4d45
adding macros
da2e5d4
gr sparse vec template stuff
d928055
working on gr_sparse vec templates
aldenwalker c14897c
working on several sparse vec functions
701127c
added some other creation and tests
efe5d72
starting to try to compile
511ab5c
compiles
9cc6a03
added into dense functions
3d6ea81
working on documentation
b6617f7
more documentation
3b42d5d
cmake and compiling
c39f222
working on tests and get/set individual entries
e1ce9e5
find/set entry
bfc4bca
debugging sparse vec creation test failure
edca4ac
unsorted creation test passing
aldenwalker fd2fad5
added conversion test
aldenwalker 94aa615
Added shallow transpose macro
49b1a8e
Merge remote-tracking branch 'overcrimp2/sparse3_akwalke' into sparse3
1427ffa
Some nomenclature changes
3f53d01
Beginning of gr sparse matrix
72d3b91
Bug fix
ae7f8af
Forgot to save
9a75954
Fixed setting functions
a687079
A few more functions
967ee80
Added negation
2aa7bb5
Added scaling ops
cb8c911
Sparse vector and matrix multiplication
1d22885
Merge branch 'main' into sparse3
26cd947
Fixed documentation
98ecdf7
Bug fixes
5da9446
Changed more col to ind, ind to nzidx
4eb5ca1
Updated sparse vector docs
34908ed
Finished basic API analogous to sparse vector
fd083fd
Merge branch 'main' into sparse3
6108953
Fixed test
d9cebe6
Various nomenclature changes, added randtest, testing more rings
e931f8d
More doc fixes
6b3ed70
More doc fixes
9436272
Fixed equality and tested scaling
1565c9b
Fixed bug in riffling
6eb88f7
Fixed other testing
1a49b2d
Weakened test because of ring compatibility issues, decent coverage now
9bce9ee
Added missed tests
0b4ac8b
Moved inline arithmetic functions to files
a3be3d5
Moved column permutations to file
ca8e38e
Added newline
ecf1f65
Fixed a few bugs, test for generation and conversion
1152d15
More conversion tests
971f11a
A little more coverage
0b5eee6
Basic stuff mostly tested, have most of the functionality for solving
71eb7d2
Added solvers, compiles but will not work yet
a3cdc82
Fixed tests
fe248bd
Everything but block lanczos works
61fc72c
Merged upstream
f9f9e51
Forgot a file
ad3dfe5
Updated documentation, added functions to update a dense matrix with …
7b5ec2b
fix sparse_vec arithmetic for length zero
fredrik-johansson 4ec61b0
Added LU and rref
83ebaaa
Forgot to add files
4996074
Merge branch 'main' into sparse3
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 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 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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,24 @@ | ||
/* | ||
Copyright (C) 2022 Fredrik Johansson | ||
|
||
This file is part of FLINT. | ||
|
||
FLINT is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (LGPL) as published | ||
by the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. See <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "gr_mat.h" | ||
|
||
int | ||
gr_mat_addmul_generic(gr_mat_t D, const gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) | ||
{ | ||
return gr_mat_mul_classical(C, A, B, ctx); | ||
} | ||
|
||
int | ||
gr_mat_addmul(gr_mat_t D, const gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) | ||
{ | ||
return gr_mat_addmul_generic(D, C, A, B, ctx); | ||
} |
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,117 @@ | ||
/* | ||
Copyright (C) 2022 Fredrik Johansson | ||
|
||
This file is part of FLINT. | ||
|
||
FLINT is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (LGPL) as published | ||
by the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. See <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include "gr_vec.h" | ||
#include "gr_mat.h" | ||
|
||
int | ||
gr_mat_addmul_classical(gr_mat_t D, const gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) | ||
{ | ||
slong ar, ac, br, bc, i, j, sz; | ||
int status; | ||
|
||
ar = gr_mat_nrows(A, ctx); | ||
ac = gr_mat_ncols(A, ctx); | ||
br = gr_mat_nrows(B, ctx); | ||
bc = gr_mat_ncols(B, ctx); | ||
|
||
if (gr_mat_is_compatible(C, D, ctx) == T_FALSE || ac != br || ar != gr_mat_nrows(C, ctx) || bc != gr_mat_ncols(C, ctx)) | ||
return GR_DOMAIN; | ||
|
||
if (br == 0) | ||
{ | ||
return GR_SUCCESS; | ||
} | ||
|
||
status = GR_SUCCESS; | ||
|
||
if (A == D || B == D) | ||
{ | ||
gr_mat_t T; | ||
gr_mat_init(T, ar, bc, ctx); | ||
status |= gr_mat_addmul_classical(T, C, A, B, ctx); | ||
status |= gr_mat_swap_entrywise(T, D, ctx); | ||
gr_mat_clear(T, ctx); | ||
return status; | ||
} | ||
|
||
sz = ctx->sizeof_elem; | ||
|
||
if (br == 1) | ||
{ | ||
for (i = 0; i < ar; i++) | ||
{ | ||
for (j = 0; j < bc; j++) | ||
{ | ||
if (C != D) | ||
status |= gr_set(GR_MAT_ENTRY(D, i, j, sz), GR_MAT_ENTRY(C, i, j, sz), ctx); | ||
status |= gr_addmul(GR_MAT_ENTRY(D, i, j, sz), | ||
GR_MAT_ENTRY(A, i, 0, sz), | ||
GR_MAT_ENTRY(B, 0, j, sz), ctx); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
gr_ptr tmp; | ||
gr_method_void_unary_op set_shallow = GR_VOID_UNARY_OP(ctx, SET_SHALLOW); | ||
TMP_INIT; | ||
|
||
TMP_START; | ||
tmp = TMP_ALLOC(sz * br * bc); | ||
|
||
/* Make a shallow transpose so that we can use dot products. | ||
Inline common sizes. (Caution: are we sure about the alignment? | ||
Some asserts would be nice here.) | ||
Todo: we may want inlining in nonsingular_solve etc. as well. */ | ||
for (i = 0; i < br; i++) | ||
{ | ||
for (j = 0; j < bc; j++) | ||
{ | ||
switch (sz) | ||
{ | ||
#if 0 | ||
case 1: | ||
((int8_t *) GR_ENTRY(tmp, j * br + i, 1))[0] = ((int8_t *) GR_MAT_ENTRY(B, i, j, 1))[0]; | ||
break; | ||
case 2: | ||
((int16_t *) GR_ENTRY(tmp, j * br + i, 2))[0] = ((int16_t *) GR_MAT_ENTRY(B, i, j, 2))[0]; | ||
break; | ||
case 4: | ||
((int32_t *) GR_ENTRY(tmp, j * br + i, 4))[0] = ((int32_t *) GR_MAT_ENTRY(B, i, j, 4))[0]; | ||
break; | ||
#if FLINT_BITS == 64 | ||
case 8: | ||
((int64_t *) GR_ENTRY(tmp, j * br + i, 8))[0] = ((int64_t *) GR_MAT_ENTRY(B, i, j, 8))[0]; | ||
break; | ||
#endif | ||
#endif | ||
default: | ||
set_shallow(GR_ENTRY(tmp, j * br + i, sz), GR_MAT_ENTRY(B, i, j, sz), ctx); | ||
} | ||
} | ||
} | ||
|
||
for (i = 0; i < ar; i++) | ||
{ | ||
for (j = 0; j < bc; j++) | ||
{ | ||
status |= _gr_vec_dot(GR_MAT_ENTRY(D, i, j, sz), GR_MAT_ENTRY(C, i, j, sz), 0, | ||
GR_MAT_ENTRY(A, i, 0, sz), GR_ENTRY(tmp, j * br, sz), br, ctx); | ||
} | ||
} | ||
|
||
TMP_END; | ||
} | ||
|
||
return status; | ||
} |
Oops, something went wrong.
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.
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.
These should remain as functions; someone might want to call them externally.