Skip to content

Instantly share code, notes, and snippets.

@lucainnocenti
Last active November 11, 2021 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucainnocenti/003e57bed88808adc0b7bfcce66ff028 to your computer and use it in GitHub Desktop.
Save lucainnocenti/003e57bed88808adc0b7bfcce66ff028 to your computer and use it in GitHub Desktop.
Dynamically visualise dual and parseval frames
getDualBasis[vecs_List] := With[{
sMatrix = Total[KroneckerProduct[#, Conjugate@#] & /@ vecs]
},
Dot[Inverse@sMatrix, #] & /@ vecs
];
getParsevalFrame[vecs_List] := With[{
sMatrix = Total[KroneckerProduct[#, Conjugate@#] & /@ vecs]
},
Dot[MatrixFunction[Sqrt, Inverse@sMatrix], #] & /@ vecs
];
DynamicModule[
{pts = {{1, 0}, {0, 1}, {1, 1}}},
Graphics[{
PointSize@0.02, {Gray, Point@{0, 0}},
Dynamic[Point /@ pts],
(* draw labels on base vecs *)
Dynamic[Text[Style[#, Bold, Italic, Larger],
pts[[#]], {-2, -2}] & /@ Range@Length@pts],
Locator[Dynamic@pts[[#]], None] & /@ Range@Length@pts,
(* draw dual vecs *)
Dynamic@With[{dualVecs = getDualBasis@pts},
{
Text[Style[#, Bold, Italic, Orange, Larger],
dualVecs[[#]], {-2, -2}] & /@ Range@Length@pts,
Orange, {Point@#, Arrow@{{0, 0}, #}} & /@ dualVecs
}
],
(* draw parseval frame *)
Dynamic@With[{parsevalVecs = getParsevalFrame@pts},
{
Text[Style[#, Bold, Italic, Cyan, Larger],
parsevalVecs[[#]], {-2, -2}] & /@ Range@Length@pts,
Cyan, {Point@#, Arrow@{{0, 0}, #}} & /@ parsevalVecs
}
]
},
PlotRange -> ConstantArray[{-2, 2}, 2], GridLines -> Automatic,
Frame -> True, Axes -> True
]
]
@lucainnocenti
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment