Skip to content

Transformation matrix calculation in spinwave.m introduces instability (and is inefficient) #232

@alexhroom

Description

@alexhroom

V(:,:,ii) = inv(K)*U*diag(sqrt(gCommd.*omega(:, hklIdxMEM(ii)))); %#ok<MINV>

The calculation calculates the transformation matrix $V$ as $V = K^{-1} U E^{1/2}$. Calculating the inverse of a matrix to use in a calculation is usually not recommended as it is quite unstable (MATLAB docs find for a 500x500 matrix the error is 10^9 larger!) compared to calculating $V$ as the solution to the linear system $KV = UE^{1/2}.$

The solve would also be more efficient - inv(K) works by solving the linear system $K X = I$ for $X$ (so we get that $X$ is $K^{-1}$). So if we calculate inv(K) purely to calculate V, we are doing a linear system solve and then two unnecessary matrix multiplications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions