SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mag.h File Reference
#include "Snap.h"
#include "kronecker.h"

Go to the source code of this file.

Classes

class  TMAGAffMtx
 
class  TMAGNodeSimple
 
class  TMAGNodeBern
 
class  TMAGNodeBeta
 
class  TMAGParam< TNodeAttr >
 
class  TMAGFitBern
 

Typedefs

typedef TVec< TMAGAffMtxTMAGAffMtxV
 

Functions

const double LogSumExp (const double LogVal1, const double LogVal2)
 
const double LogSumExp (const TFltV &LogValV)
 
const double LogSumExp (const double *LogValArray, const int Len)
 

Typedef Documentation

Definition at line 62 of file mag.h.

Function Documentation

const double LogSumExp ( const double  LogVal1,
const double  LogVal2 
)

Definition at line 675 of file mag.cpp.

675  {
676  double MaxExp = (LogVal1 > LogVal2) ? LogVal1 : LogVal2;
677  double Sum = exp(LogVal1 - MaxExp) + exp(LogVal2 - MaxExp);
678  return (log(Sum) + MaxExp);
679 }
const double LogSumExp ( const TFltV LogValV)

Definition at line 681 of file mag.cpp.

681  {
682  const int Len = LogValV.Len();
683  double MaxExp = -DBL_MAX;
684 
685  for(int i = 0; i < Len; i++) {
686  if(MaxExp < LogValV[i]) { MaxExp = LogValV[i]; }
687  }
688 
689  double Sum = 0.0;
690  for(int i = 0; i < Len; i++) {
691  Sum += exp(LogValV[i] - MaxExp);
692  }
693 
694  return (log(Sum) + MaxExp);
695 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
const double LogSumExp ( const double *  LogValArray,
const int  Len 
)

Definition at line 697 of file mag.cpp.

697  {
698  TFltV TmpV(Len);
699  for(int i = 0; i < Len; i++) { TmpV[i] = LogValArray[i]; }
700  return LogSumExp(TmpV);
701 }
const double LogSumExp(const double LogVal1, const double LogVal2)
Definition: mag.cpp:675