12:06 AM
@CATrevillian I had a look at the paper. Note that their "Lemma 2" computes the square of the absolute value of an eigenvector component.
If you need phase information, you won't get it from that.
Note also that the formula also depends on the eigenvalues of submatrices. Presumably one could construct a recursive method from this, but it is not clear to me if this is competitive with standard methods.

@J.M.willbebacksoon I will be consulting my advisor on this as we work in micromagnetics and seemingly this may play a role in speeding some computations? Your point re “Lemma 2” is a valuable one, though. It appears to be three independent proofs that are contained in the paper, so perhaps there is a workaround to that? @halirutan I have also come to understand this quite recently!

@CATrevillian I thought you do some NMR physics. Unfortunately, phases play a very important role there :)

12:42 AM
@halirutan right you are! Spin echos (&their algorithms) are really cool & curious things for me, at least in that area. What can I say though, I like magnets! Magnetism & spin dynamics are what I study. Specifically I work with a group that takes experimental data, determines models & analytical descriptions, then finds ways to learn more experimentally & improve the models! (& Maybe make a device or three!)

@CATrevillian Yep, we basically do the same.
I'm currently wrapping my head about some nasty susceptibility artifacts that come from air-bubbles in a brain and which completely destroy the nice mono-exponential decay model in this area.

1 hour later…
1:50 AM
posted on November 16, 2019

This package provides monad-like implementation for for the following Latent Semantic Analysis (LSA) main sequence of steps : ingesting a collection of documents; creating a document-term matrix (linear vector space representation); facilitating term-paragraph matrix creation or other breakdowns; apply different type of term-weighting functions; extract topics using NNMF (or SVD) with

2:00 AM
@halirutan ah very cool, not the air bubbles being there though! So how do the bubbles get there? And you can view them with MRI? Does T1 or T2 matter more in that case?

@CATrevillian Well, the bubbles are from the preservation process and when you scan them, the difference between air and tissue introduces local magnetic fields that disturb the frequency/phase localization.
And we are not so much interested in T1/T2 images by themselves. We create multiparametric maps.

2:23 AM
@J.M.willbebacksoon On the other hand, that kind of recursive relationship could help with pure analytical work
As in, I want to know how some wavefunction (i.e. and eigenvector) relates to the energies of the Hamiltonian it rises from
If I have a nice way of describing the Hamiltonian in some near-analytic way I can learn something about the fundamental physics of my system without going through the messiness of actually trying to derive my eigenvectors
I can instead just (potentially) figure something out by induction
@J.M.willbebacksoon For many physical systems that kind of phase information can also sometimes be reconstructed post-hoc
I.e. in the world of vibrational wavefunctions we know they must have the symmetries allowed by the point-group of the molecule
And from that we can reconstruct phase relationships

@b3m2a1 what you just said makes me think/hope my advisor will be super pumped about this, then! Because we have exactly (near analytically) that, re the Hamiltonian :3

@J.M.willbebacksoon one cute thing that I just thought up. In my work we often look at simplified models to probe the physics underlying some vibrational spectrum. We usually do this by build some simple base model and then reintroducing some form of coupling.
But say you have some molecular modes `nu_0, nu_1, ...` and you want to probe how they couple
Well if you removed `nu_i` then your submatrix would be the Hamiltonian for a system where you force `nu_i` to be decoupled from the other modes
And this gives us an analytic way to relate that submatrix to the total Hamiltonian
(since it's just the `ith` minor of our system)

@halirutan & that comes from microscopy or spectroscopy? I don’t know much yet, but I do have to write a lab report or two on each of those this weekend, so, then I’ll know slightly more, but still less than very much, hah!
@b3m2a1 so then, barring my broken understanding of things, how might that assist with knowing more about the coupling of the modes?

@CATrevillian What comes from what? Now you lost me.

@CATrevillian we care a lot about how coupling two modes shifts their frequencies
This gives us a analytical relationship if we know the frequencies of the subsytem
Even Corollary 3 could be useful vis-a-vis probing the symmetries of our systems
It would take some thought as to how we could use it directly, though

2:54 AM
@halirutan multiparametric maps

@CATrevillian MPMs can be calculated by combining different echoes (and contrasts) to get, e.g. an R2* map.

2 hours later…
4:38 AM
@b3m2a1 "could help with pure analytical work" - that after all is the context the physicists and Terry Tao were working in. :)
@b3m2a1 Indeed it can be considered a recursive relationship between the eigenvalues of the original matrix and its minors. If the system is nicely structured, (e.g. if it's Hermitian like in most chemical/physical applications), it's lovely.

8 hours later…
12:10 PM
@b3m2a1 I have a question about the mutation handler stuff that you showed me a long time ago. I'm trying to use it to update the value of a symbol inside a container, where the container is itself assigned to some variable. Here's a non-working example:
```Clear[obj];

createObject[] := container[Unique["test`x"]]
obj = createObject[];```
```myMutationHandler // ClearAll
SetAttributes[myMutationHandler, HoldAllComplete]

myMutationHandler[Set[obj_Symbol, val_]] := obj[[1]] = val
myMutationHandler[___] := Language`MutationFallThrough

Language`SetMutationHandler[container, myMutationHandler]```
@b3m2a1 I understand that this can't work, but what I'm wondering is if you know a workaround that would let me use `Set` on `obj` so that the underlying `test`x123` variable gets updated?
In my real use case, `container` is going to have some other information as well `container[test`x123, stuff, stuff]` and the extra information will be used to set `test`x123`.

4 hours later…
4:20 PM
Always very impressed by the breadth of knowledge in this chat room!

2 hours later…
6:09 PM
@C.E. actually this can work if memory serves. Try looking up the Q/A where I talk about making a listener variable. I think I used that pattern there.

2 hours later…
7:55 PM
@b3m2a1 The answer is here and I looked through the code. I don't see that the code sets a symbol hidden inside the object like this. The general pattern I do get to work, as you may recall I use it in jsoupLink. But not writing to a symbol like this, that I'm afraid I cannot get to work.
@b3m2a1 Do you think I'm going about it the right way at all? What I'm trying to do is to create a mutable data structure. So I'll have some kind of expression, and inside this expression I'll have a symbol, and this symbol will reference a matrix. And this matrix will be manipulated by functions that are defined to work with that type of expression. And the raw data of all such expressions will be stored as variables in a special context.

@C.E. I think this is the only change you need:
`myMutationHandler[Set[obj_Symbol, val_]] := With[{s = obj[[1]]}, s = val];`
The issue is that `___` was too general a pattern so it caught `obj[[1]] = val` too
@C.E. I do exactly this kind of thing here
So I believe in its utility

@b3m2a1 The first time I run Set, e.g. obj = 10, it sets the variable. The second time, e.g. obj = 15, it says Cannot assign to raw object 10

@C.E. That's because you'll probably actually need to use, e.g. `Extract` :)
Alternately you can set up two mutation handle rules:
```myMutationHandler[Set[obj_Symbol, val_]] := With[{s = s}, s = val];
myMutationHandler[container[key_Symbol], val_]] := (key = val);```
Then make `container` `HoldAll`

8:16 PM
@b3m2a1 I'm confused about mutation handlers. So key = val will invoke the mutation handler attached to `container` even though `container` does not appear in that expression? In either case, I can't get this to write anything to the variable at all (after changing obj to s), possibly because of the `HoldAll` or other things.

Yeah `MutationHandler` is a very general purpose hook it seems
Which variable?
Sorry there are lots floating around

Well, I create an object like this:
```SetAttributes[container, HoldAll]
createObject[] := With[{s = Unique["test`x"]}, container[s]]
obj = createObject[];```
And the purpose of the code is to write to the symbol created there.
So I use ?? test`* to see what symbol was created, but then when I evaluate test`x11, I see that the value wasn't set when I did obj = 10;
Or just evaluate obj to see what symbol it encapsulates.

Here's the architecture I'd use:
```Clear[container];
(* create container object infrastructure *)
container~SetAttributes~HoldAll;
containerQ[container[var_Symbol]] := True;
containerQ[___] := False;
container[] :=
With[{s = Unique[containerValue]},
SetAttributes[s, Temporary]; s = Null; container[s]
];
setContainerValue[container[var_], val_] := var = val;
getContainerValue[container[var_]] := var;
container /: Normal[c_container?containerQ] := getContainerValue[c]

(* bind simplest mutation handler *)
ClearAll[myMutationHandler];```
This works like:
```obj // Clear
obj = container[];

obj = 2

2

obj

container[containerValue\$701768]

obj // Normal

2```
I always make my `MutationHandler` calls delegate to some accessor method
Easier to reason about that way
And I always write some form of `objectQ` method
So that I can minimize the amount of pattern matching I have to directly cook into my interface

8:40 PM
@b3m2a1 That looks very good but there is one thing I can't figure out
@b3m2a1 In that screenshot we can see that once I've evaluated `obj`, it stops working.

Weird I don't see that

what the...
Yours makes more sense. I don't see anything attached to `obj` that could have side-effects...

Is there a lingering definition?
What could be happening is that `obj` is somehow getting bound to `obj`
Which I guess in some weird way due to the `HoldAll` wouldn't cause a recursion error
I.e. something like this:
```a = Hold[a]

Hold[a]

a

Hold[a]

a[[1]]

Hold[a]```

@b3m2a1 I asked myself, "what setting might a pro like b3m2a1 be using, that I'm not using?" and then I put `\$HistoryLength = 0;` and then it started working like for you :P

8:55 PM
```\$HistoryLength

\[Infinity]```
?_?
Which version are you on?

12.0.0.0

Hmm... me too
I'm willing to bet this is something to do with either the FE or some weird edge case in Mathematica evaluation semantics
Or...
Not sure

well, there's definitely a connection to `HistoryLength` on my end, because it's reproducible.

Yep
Here's a question: what happens if you do `obj;` instead of letting it display?
That would bind to `Out` but wouldn't invoke anything in the FE
(I assume)

@b3m2a1 that still makes it not work

9:02 PM
Interesting so there's something weird going on with `Out`. Here's something to check: try putting an `Echo` in `setContainerValue` to see if it's invoking.
If so, on your version of Mathematica but not on mine they're re-evaluating things before they go into `Out`

It is only invoked when assigning `obj = 5`, not later
I'm on MacOS btw

Weeeeeeeeeeeeeeird
I'm on Mac too
I'm super confused
Do you have the suggestions bar thing enabled?
Also afterwards is it just that `container` has been cleared of its `UpValues`?
Or did the value of the held symbol change?

@b3m2a1 ah, disabling the suggestion bar also works. If I had kept thinking in the "what might a pro have done" I would've gotten there too eventually ;)

@C.E. Ahh I'm sure the suggestions bar and `\$HistoryLength` talk to each other so that makes sense
Or rather `Out` and the suggestions bar
Bizarro that the suggestions bar manages to break the code

The upvalue for normal is still there btw. Yeah, it happened quite a lot in the first release of the suggestion bar IIRC but I haven't seen it in quite a while.
I will simply disable it and keep working on this approach. I am quite excited about an idea and this I think will allow me to implement it, so this is really great :)
thanks