I'm trying to project new data rows into a prior SVD space. ie. I want to solve for `u`

in `x = udv'`

which I think is `u = xvd(-1)`

(e.g. from here https://blog.statsbot.co/singular-value-decomposition-tutorial-52c695315254).

From the output below I guess I must be wrong. Can some kind person help please?

```
x <- scale(iris[-5])
# svd
eg <- svd(x)
u <- eg$u
d <- diag(eg$d)
v <- eg$v
# check x = udv'
head(x)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> [1,] -0.8976739 1.01560199 -1.335752 -1.311052
#> [2,] -1.1392005 -0.13153881 -1.335752 -1.311052
#> [3,] -1.3807271 0.32731751 -1.392399 -1.311052
#> [4,] -1.5014904 0.09788935 -1.279104 -1.311052
#> [5,] -1.0184372 1.24503015 -1.335752 -1.311052
#> [6,] -0.5353840 1.93331463 -1.165809 -1.048667
head(u %*% d %*% t(v))
#> [,1] [,2] [,3] [,4]
#> [1,] -0.8976739 1.01560199 -1.335752 -1.311052
#> [2,] -1.1392005 -0.13153881 -1.335752 -1.311052
#> [3,] -1.3807271 0.32731751 -1.392399 -1.311052
#> [4,] -1.5014904 0.09788935 -1.279104 -1.311052
#> [5,] -1.0184372 1.24503015 -1.335752 -1.311052
#> [6,] -0.5353840 1.93331463 -1.165809 -1.048667
# project onto u = xvd(-1)
head(x %*% v %*% d^-1)
#> [,1] [,2] [,3] [,4]
#> [1,] NaN NaN NaN NaN
#> [2,] Inf NaN NaN NaN
#> [3,] NaN NaN NaN NaN
#> [4,] NaN -Inf NaN NaN
#> [5,] -Inf -Inf -Inf -Inf
#> [6,] NaN NaN NaN -Inf
```

^{Created on 2019-04-01 by the reprex package (v0.2.1)}