Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Python
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 20-Oct-20 6:16am
v3

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!
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900