tensor_methods

Tensor Methods for DS and SC
git clone git://popovic.xyz/tensor_methods.git
Log | Files | Refs

err_tsvd.jl (439B)


      1 #/usr/bin/julia
      2 
      3 using LinearAlgebra
      4 using Plots
      5 using Maxvol
      6 using TSVD
      7 using LaTeXStrings
      8 
      9 function get_errors_tsvd(M ,k)
     10     U, s, V = tsvd(M, k)
     11     M_hat = U * Diagonal(s) * transpose(V)
     12     dM = M_hat - M
     13     return [norm(dM), norm(dM, Inf)]
     14 end;
     15 
     16 function sort_out_values(M, x, error_function)
     17     errors = [error_function(M, i) for i in x]
     18     y_f = [i[1] for i in errors]
     19     y_m = [i[2] for i in errors]
     20     return y_f, y_m
     21 end;