14,638,817 members
Rate this:
See more:
```def function1(W):
n = W.shape[0]
m = W.shape[1]
keep = []
for i in range(m):
mn = W[True - np.isnan(W[:,i]),i].mean()
W[np.isnan(W[:,i]),i] = mn
vr = W[:,i].var()
if vr == 0: continue

keep.append(i)
W[:,i] = (W[:,i] - mn) / np.sqrt(vr)

W = W[:,keep]
K = matrixMult(W,W.T) * 1.0/float(m)
return K```

What I have tried:

I tried using Eigen library.
But it didn't come out as I wanted.
I want to use Eigen library.
Posted
Updated 10-Jun-20 0:46am
v2

Rate this:

## Solution 1

Automatically "converting code" between two languages is rarely a good idea: it does not produce good code in the target language. Particularly when you want it to work with a specific library package that the original code was not designed for.

Instead, use the original code as a specification and write fresh code in the target language to meet that spec. That means doing four things:
1) Leaning the original code language.
2) Understanding what the original code is doing, and how it does it.
3) Learning the target code language.
4) Writing fresh code to use the library you have selected.

Good luck!
Rate this:

## Solution 2

OriginalGriff is absolutly right and if you want to use the Eigen library than you should visit some Eigen library introduction and also the tutorial at the end.

Than it should be a piece of cake. But we dont know about this library and its usage.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 85 Dave Kreskowiak 74 F-ES Sitecore 50 Maciej Los 25 Member 12901943 25
 OriginalGriff 4,725 Sandeep Mewara 2,636 Richard Deeming 1,544 Richard MacCutchan 1,499 CPallini 1,458

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100