-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add Vector == ZZ method #3606
base: development
Are you sure you want to change the base?
Add Vector == ZZ method #3606
Changes from all commits
f0815b9
0aba649
07cf2da
6f014fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,8 +102,10 @@ Matrix _ Sequence := RingElement => (m,ind) -> ( | |
else error "expected a sequence of length two" | ||
) | ||
|
||
Number == Matrix := | ||
RingElement == Matrix := (r,m) -> m == r | ||
Number == Matrix := | ||
RingElement == Matrix := | ||
Number == Vector := | ||
RingElement == Vector := (r,m) -> m == r | ||
|
||
Matrix == Matrix := (f,g) -> ( | ||
if source f === source g | ||
|
@@ -115,26 +117,34 @@ Matrix == Matrix := (f,g) -> ( | |
target f == target g and | ||
raw(super f * inducedMap(source f, source g)) === raw super g | ||
) | ||
Vector == Matrix := (v,m) -> matrix v == m | ||
Matrix == Vector := (m,v) -> m == matrix v | ||
|
||
Matrix == Number := | ||
Matrix == RingElement := (m,f) -> m - f == 0 -- slow! | ||
Vector == Number := | ||
Vector == RingElement := (v,f) -> matrix v == f | ||
Matrix == ZZ := (m,i) -> if i === 0 then rawIsZero m.RawMatrix else m - i == 0 | ||
|
||
Matrix + Matrix := Matrix => ( | ||
(f,g) -> map(target f, source f, reduce(target f, raw f + raw g)) | ||
) @@ toSameRing | ||
Matrix + RingElement := (f,r) -> if r == 0 then f else f + r*id_(target f) | ||
RingElement + Matrix := (r,f) -> if r == 0 then f else r*id_(target f) + f | ||
Number + Matrix := (i,f) -> if i === 0 then f else i*id_(target f) + f | ||
Matrix + Number := (f,i) -> if i === 0 then f else f + i*id_(target f) | ||
Matrix + RingElement := | ||
Matrix + Number := (f,r) -> if r == 0 then f else f + r*id_(target f) | ||
RingElement + Matrix := | ||
Number + Matrix := (r,f) -> f + r | ||
Vector + Number := Vector + RingElement := (v,r) -> vector(matrix v + r) | ||
Number + Vector := RingElement + Vector := (r,v) -> vector(r + matrix v) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i1 : Number + Vector := RingElement + Vector := (r,v) -> vector(r + matrix v);
i2 : 1 + (coker matrix {{ 10 }})_0
stdio:1:58:(3):[1]: error: expected source to be free with rank 1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is coming from i1 : code (vector, Matrix)
o1 = -- code for method: vector(Matrix)
M2/Macaulay2/m2/modules.m2:66:17-69:5: --source code:
vector Matrix := f -> (
if not isFreeModule source f or numgens source f =!= 1 then error "expected source to be free with rank 1";
new target f from {f}
) Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not the problem. Single generators of any module whatsoever are vectors. The implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this seems to be a problem with matrix addition: i1 : M = coker matrix 10;
i2 : A = map(M, ZZ^1, 1)
o2 = | 1 |
1
o2 : Matrix M <-- ZZ
i3 : 1 + A
o3 = | 2 |
o3 : Matrix M <-- M
i4 : A + 1
o4 = | 2 |
1
o4 : Matrix M <-- ZZ Shouldn't they both have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just pushed a new commit that should fix this |
||
|
||
Matrix - Matrix := Matrix => ( | ||
(f,g) -> map(target f, source f, reduce(target f, raw f - raw g)) | ||
) @@ toSameRing | ||
Matrix - RingElement := (f,r) -> if r == 0 then f else f - r*id_(target f) | ||
RingElement - Matrix := (r,f) -> if r == 0 then -f else r*id_(target f) - f | ||
Number - Matrix := (i,f) -> if i === 0 then -f else i*id_(target f) - f | ||
Matrix - Number := (f,i) -> if i === 0 then f else f - i*id_(target f) | ||
Matrix - RingElement := | ||
Matrix - Number := (f,r) -> if r == 0 then f else f - r*id_(target f) | ||
RingElement - Matrix := | ||
Number - Matrix := (r,f) -> -f + r | ||
Vector - Number := Vector - RingElement := (v,r) -> vector(matrix v - r) | ||
Number - Vector := RingElement - Vector := (r,v) -> vector(r - matrix v) | ||
|
||
- Matrix := Matrix => f -> new Matrix from { | ||
symbol ring => ring f, | ||
|
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 get that this is necessary but looking at it I realized I hate the way things are, so opened #3608.