SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
numpy.cpp
Go to the documentation of this file.
1 namespace TSnap {
4 void TIntVToNumpy(TIntV& IntV, int* IntNumpyVecOut, int n) {
5  int limit = MIN(IntV.Len(), n);
6 
7  for (int i=0; i < limit; i++) {
8  IntNumpyVecOut[i] = IntV[i];
9  }
10 }
11 
12 
15 void TFltVToNumpy(TFltV& FltV, float* FltNumpyVecOut, int n) {
16  int limit = MIN(FltV.Len(), n);
17 
18  for (int i=0; i < limit; i++) {
19  FltNumpyVecOut[i] = static_cast<float>(FltV[i]);
20  }
21 }
22 
25 void NumpyToTIntV(TIntV& IntV, int* IntNumpyVecIn, int n) {
26  for (int i = 0; i < n; ++i) {
27  IntV[i] = IntNumpyVecIn[i];
28  }
29 }
30 
33 void NumpyToTFltV(TFltV& FltV, float* FltNumpyVecIn, int n) {
34  for (int i = 0; i < n; ++i) {
35  FltV[i] = FltNumpyVecIn[i];
36  }
37 }
38 }
Main namespace for all the Snap global entities.
Definition: alg.h:1
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
#define MIN(a, b)
Definition: bd.h:346
void NumpyToTIntV(TIntV &IntV, int *IntNumpyVecIn, int n)
Converts NumpyArray to TIntV.
Definition: numpy.cpp:25
void TFltVToNumpy(TFltV &FltV, float *FltNumpyVecOut, int n)
Converts TFltV to Numpy array.
Definition: numpy.cpp:15
void NumpyToTFltV(TFltV &FltV, float *FltNumpyVecIn, int n)
Converts NumpyArray to TFltV.
Definition: numpy.cpp:33
void TIntVToNumpy(TIntV &IntV, int *IntNumpyVecOut, int n)
Converts TIntV to Numpy array.
Definition: numpy.cpp:4
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430