-
Notifications
You must be signed in to change notification settings - Fork 252
And mathML(Complex) and related updates #3726
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
And mathML(Complex) and related updates #3726
Conversation
It should look the same. |
great. yeah |
Yikes! Apparently constructing these expressions isn't very efficient: i9 : elapsedTime T = tateExtension W;
-- .420421s elapsed
i10 : elapsedTime expression T;
-- 12.5284s elapsed I'll see if I can improve things. |
one potential issue (I'm not sure if that's the one you're facing in your example) is that you probably don't want to take the expression ( |
Lol yeah -- that's exactly what's happening: i12 : profileSummary
o12 = #run %time position
1 93.71 src/macaulay2/M2/M2/Macaulay2/m2/chaincomplexes.m2:135:4-137:51
16 93.7 src/macaulay2/M2/M2/Macaulay2/m2/matrix.m2:217:4-217:42
4586444 44.17 src/macaulay2/M2/M2/Macaulay2/m2/polyrings.m2:205:61-205:73 4.5 million calls to |
on |
What's the point of an intermediary type ComplexExpression? I want to remove SheafExpression already. |
For the time being, while we have two distinct complex types with Also, based on the Expression docs, it seems like having expression classes for mathematical objects is part of the design of the language:
What's the problem with |
772d9ef
to
90dfa5a
Compare
I think the only problem with your |
94197c7
to
ba139fa
Compare
Oh ok -- I didn't think about zero matrices. I just used your commit instead. |
ba139fa
to
3639dee
Compare
Hmm, there's something wrong with i2 : toString short map(ZZ^2, ZZ^2, 0)
stdio:2:8:(3)]: error: expected a list, sequence, string, net, hash table, database, or dictionary |
interesting. this is a good opportunity to clean up/debug this code... |
11b9d1f
to
44d25f9
Compare
else if hasAttribute(M, ReverseDictionary) | ||
then getAttribute(M, ReverseDictionary)) | ||
|
||
short Module := M -> moduleAbbrv M ?? expression M |
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 don't understand why you removed the second input of moduleAbbrv
, when this could have been implemented as:
short Module := M -> moduleAbbrv M ?? expression M | |
short Module := M -> moduleAbbrv(M, expression M) |
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've always thought that moduleAbbrv
's two inputs were kind of clunky. For example, in Matrix.AfterPrint
, we don't need the second input at all -- if we can't abbreviate the module, then we just don't print anything. I figured this was an opportunity to update it.
I've updated the behavior of |
44d25f9
to
ed5bf36
Compare
@sashahbc: Sorry to keep bugging you with these Test 7 is failing on the builds for this PR: i9 : assert(presentation RD2 == matrix {{y_1,0},{0,y_1^2},{0,0}})
stdio:10:6:(3): error: assertion failed The rows were permuted a bit from the expected matrix: i55 : presentation RD2
o55 = | 0 0 |
| y_1 0 |
| 0 y_1^2 |
3 2
o55 : Matrix Q <-- Q From what I can tell, directSum for mu in keys eigenchars list ( Since |
Yeah that's definitely the problem. Not sure what the best solution would be. I was hoping |
It seems like a bad idea because it's a probabilistic test but could we do |
I suppose that would work. Is it okay that the order of the rows isn't deterministic, though? |
Yeah I am a bit uncomfortable with the order changing. Mahrud had a suggestion which I'll make a PR for in a sec. |
ec0f2ee
to
e41348b
Compare
M2/Macaulay2/m2/expressions.m2
Outdated
Blocks => null, | ||
Degrees => null, | ||
MutableMatrix => false, | ||
zero => null}; |
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.
any reason zero
is the only lowercase option? and incidentally which type is this zero
?
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 went with zero
since it's already exported. When it's non-null, it will be a sequence of two modules (the target and source).
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 meant, what is the class of zero
itself, not the option labelled zero.
usually it's nice if all options have the same type; which one is a matter of taste, it seems (all symbols seems the most common choice, though there's serious overhead in doing that; I would think all strings would actually make more sense, but it's rarely used. I digress)
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.
This is an excellent question! I thought I'd put symbol zero
here, but I didn't. And zero
is a function closure, which should have raised an error...
i1 : new OptionTable from {zero => null}
stdio:1:0:(3): error: expected option key to be a symbol, a string, or a type
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.
Ohhh I figured it out -- zero
is still a symbol at this point since it's not defined as a function until integers.m2, which is later in the load sequence. (Same with MutableMatrix
-- it's a type defined in mutablemat.m2, but it's a symbol here).
I'll change this so they're both explicitly symbols, just in case any code gets moved around
M2/Macaulay2/m2/matrix.m2
Outdated
@@ -215,6 +215,7 @@ protect Blocks | |||
blockMatrixForm=false; -- governs expression Matrix inclusion of blocks | |||
expression Matrix := m -> ( | |||
x := applyTable(entries m, expression); | |||
if #x == 0 then x = {symbol zero => (target m, source m)}; |
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 don't understand why this line is not above the previous one (why go through all the entries if the matrix is zero anyway?)
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.
err, I mean, and why the test isn't simply x==0
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.
Great point!
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.
Ok, I've updated this so expression
of a zero matrix always just uses the short form and never deals with the individual entries.
96ee033
to
95a577e
Compare
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.
This PR conflicts heavily with the chain complex changes.
Yeah, with both complex types moving to their own packages, I don't know if having a shared expression type in Core makes sense any more... I think I'll trim this down to just the |
95a577e
to
d46e46e
Compare
M2/Macaulay2/m2/chaincomplexes.m2
Outdated
@@ -137,15 +137,15 @@ net ChainComplex := C -> ( | |||
a := s#0; | |||
b := s#-1; | |||
horizontalJoin between(" <-- ", apply(a .. b,i -> | |||
stack (net moduleAbbrv(C_i, C_i)," ",net i))))) |
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.
This file is moved in the Complexes PR, so you might as well rebase on top of that PR I think.
d46e46e
to
de3a185
Compare
For nonfree modules, use the variable name if one exists. This will replace moduleAbbrv when printing complexes. We rewrite moduleAbbrv to return null when we can't abbreviate it and leave it up to the caller (now only AfterPrint for Matrix/Vector) to handle what to do with it.
de3a185
to
025a54c
Compare
This is probably not relevant to what you are doing here, but it is something that is a problem.
or even
This last one takes about 30 seconds on my laptop... |
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.
This looks good to me. Thanks! It appears that much of the discussion in the PR is related to pre-chain complex movement to OldChainComplexes, Complexes. Sorry about that!
@pzinn Is there a regression in the web printing of Complexes? Are we using something that you got rid of, without our noticing?
We introduce a new type,
ComplexExpression
, to unify the printing of both the legacyChainComplex
and the newerComplex
types. In particular, the latter didn't have amathML
method, and so they previously weren't supported in TeXmacs or Jupyter when using TeXmacs mode:Now,
net
,texMath
, andmathML
just callexpression
first, and so we only need to implement each once and they'll work for both types:A couple other related changes:
short(Module)
for use in complex expressions. It usesmoduleAbbrv
(which has been slightly rewritten to just return null instead of having a backup representation) to use the module's variable name when possible, unless the module is free over a ring that's been assigned to a variable, in which case we use that respresentation.substitute
when building a legacy complex usingchainComplex
if the differential maps are given over different rings. This is to fix some issues withvalue(ComplexExpression)
, where the differential maps areMatrixExpression
objects that may have forgotten some important info like what rings they were over.value(ComplexExpression)
isn't perfect -- it still fails in other situtations like when we've lost degree information.