Skip to content

#131 - Matrix power via square decomposition, v2#134

Merged
schillic merged 2 commits intomasterfrom
schillic/131
Feb 12, 2020
Merged

#131 - Matrix power via square decomposition, v2#134
schillic merged 2 commits intomasterfrom
schillic/131

Conversation

@schillic
Copy link
Copy Markdown
Member

Closes #131.

Currently the algorithm for the recursive call cannot be changed.


function IntervalMatrixPower(M::IntervalMatrix{T}, k::Int) where {T}
function IntervalMatrixPower(M::IntervalMatrix{T}, k::Int;
algorithm::String="power") where {T}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should algorithm be a field of the type?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking about that. It is more general to let you choose at every step, but we could at least have a fallback algorithm defined in the type maybe?

Copy link
Copy Markdown
Member

@mforets mforets Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first sight it looks better to me if the algorithm is in the type, since it is a property of how to get to M^k, and also how to get higher powers. (Of course i'm assuming that there is no mixed algorithm, but the "mixed" algorithm can be an algorithm by itself).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, we can revisit this later.

Copy link
Copy Markdown
Member Author

@schillic schillic Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Of course i'm assuming that there is no mixed algorithm, but the "mixed" algorithm can be an algorithm by itself).

Yes and no. If the mixed algorithm follows a strict pattern, it can be added as another algorithm. But adding a new algorithm for any pattern is not sustainable. Furthermore, you can imagine patterns that depend on user knowledge (like "next I need more precision") that you cannot express in a static algorithm. So I conclude that a String as a field is not sufficient. If we make the algorithm a field, it should be its own struct <:IntervalMatrixPowerAlgorithm that you can influence from outside.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #139.

b = k - a^2

# recursively compute M^a and M^b
Mᵏ = square(get(IntervalMatrixPower(pow.M, a; algorithm=algorithm)))
Copy link
Copy Markdown
Member

@mforets mforets Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is line 178 the same as get(IntervalMatrixPower(pow.M, a*a) ? (Also, this is the functionality that i was asking in this comment. I'll create an issue).

EDIT: This is now #138.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question still is why not use get(IntervalMatrixPower(pow.M, a*a; algorithm=algorithm))) here.

Copy link
Copy Markdown
Member Author

@schillic schillic Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use get(IntervalMatrixPower(pow.M, a*a; algorithm=algorithm))) here.

Because it is not equivalent. We do not use square for arbitrary square numbers but only for powers of 2.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, damn, your version was the correct one:
A^(a²) = A^(a*a) = (A^a)^a != (A^a)² for a != 2

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Matrix power via square decomposition, v2

2 participants