Click here to Skip to main content
14,638,817 members
Rate this:
Please Sign up or sign in to vote.
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

         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.
Updated 10-Jun-20 0:46am
Rate this:
Please Sign up or sign in to vote.

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:
Please Sign up or sign in to vote.

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)

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