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
TSparseColMatrix Class Reference

#include <linalg.h>

Inherits TMatrix.

Public Member Functions

 TSparseColMatrix ()
 
 TSparseColMatrix (TVec< TIntFltKdV > _ColSpVV)
 
 TSparseColMatrix (TVec< TIntFltKdV > _ColSpVV, const int &_RowN, const int &_ColN)
 
void Save (TSOut &SOut)
 
void Load (TSIn &SIn)
 
- Public Member Functions inherited from TMatrix
 TMatrix ()
 
virtual ~TMatrix ()
 
void Multiply (const TFltVV &B, int ColId, TFltV &Result) const
 
void Multiply (const TFltV &Vec, TFltV &Result) const
 
void MultiplyT (const TFltVV &B, int ColId, TFltV &Result) const
 
void MultiplyT (const TFltV &Vec, TFltV &Result) const
 
int GetRows () const
 
int GetCols () const
 
void Transpose ()
 

Public Attributes

int RowN
 
int ColN
 
TVec< TIntFltKdVColSpVV
 

Protected Member Functions

virtual void PMultiply (const TFltVV &B, int ColId, TFltV &Result) const
 
virtual void PMultiply (const TFltV &Vec, TFltV &Result) const
 
virtual void PMultiplyT (const TFltVV &B, int ColId, TFltV &Result) const
 
virtual void PMultiplyT (const TFltV &Vec, TFltV &Result) const
 
int PGetRows () const
 
int PGetCols () const
 

Detailed Description

Definition at line 55 of file linalg.h.

Constructor & Destructor Documentation

TSparseColMatrix::TSparseColMatrix ( )
inline

Definition at line 75 of file linalg.h.

75 : TMatrix() {}
TMatrix()
Definition: linalg.h:20
TSparseColMatrix::TSparseColMatrix ( TVec< TIntFltKdV _ColSpVV)
inline

Definition at line 76 of file linalg.h.

76 : TMatrix(), ColSpVV(_ColSpVV) {}
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TMatrix()
Definition: linalg.h:20
TSparseColMatrix::TSparseColMatrix ( TVec< TIntFltKdV _ColSpVV,
const int &  _RowN,
const int &  _ColN 
)
inline

Definition at line 77 of file linalg.h.

77  :
78  TMatrix(), RowN(_RowN), ColN(_ColN), ColSpVV(_ColSpVV) {}
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TMatrix()
Definition: linalg.h:20

Member Function Documentation

void TSparseColMatrix::Load ( TSIn SIn)
inline

Definition at line 83 of file linalg.h.

83  {
84  SIn.Load(RowN); SIn.Load(ColN); ColSpVV = TVec<TIntFltKdV>(SIn); }
void Load(bool &Bool)
Definition: fl.h:84
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
int TSparseColMatrix::PGetCols ( ) const
inlineprotectedvirtual

Implements TMatrix.

Definition at line 72 of file linalg.h.

72 { return ColN; }
int TSparseColMatrix::PGetRows ( ) const
inlineprotectedvirtual

Implements TMatrix.

Definition at line 71 of file linalg.h.

71 { return RowN; }
void TSparseColMatrix::PMultiply ( const TFltVV B,
int  ColId,
TFltV Result 
) const
protectedvirtual

Implements TMatrix.

Definition at line 3 of file linalg.cpp.

3  {
4  Assert(B.GetRows() >= ColN && Result.Len() >= RowN);
5  int i, j; TFlt *ResV = Result.BegI();
6  for (i = 0; i < RowN; i++) ResV[i] = 0.0;
7  for (j = 0; j < ColN; j++) {
8  const TIntFltKdV& ColV = ColSpVV[j]; int len = ColV.Len();
9  for (i = 0; i < len; i++) {
10  ResV[ColV[i].Key] += ColV[i].Dat * B(j,ColId);
11  }
12  }
13 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
Definition: dt.h:1293
#define Assert(Cond)
Definition: bd.h:251
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:565
int GetRows() const
Definition: ds.h:2186
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
void TSparseColMatrix::PMultiply ( const TFltV Vec,
TFltV Result 
) const
protectedvirtual

Implements TMatrix.

Definition at line 15 of file linalg.cpp.

15  {
16  Assert(Vec.Len() >= ColN && Result.Len() >= RowN);
17  int i, j; TFlt *ResV = Result.BegI();
18  for (i = 0; i < RowN; i++) ResV[i] = 0.0;
19  for (j = 0; j < ColN; j++) {
20  const TIntFltKdV& ColV = ColSpVV[j]; int len = ColV.Len();
21  for (i = 0; i < len; i++) {
22  ResV[ColV[i].Key] += ColV[i].Dat * Vec[j];
23  }
24  }
25 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
Definition: dt.h:1293
#define Assert(Cond)
Definition: bd.h:251
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:565
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
void TSparseColMatrix::PMultiplyT ( const TFltVV B,
int  ColId,
TFltV Result 
) const
protectedvirtual

Implements TMatrix.

Definition at line 27 of file linalg.cpp.

27  {
28  Assert(B.GetRows() >= RowN && Result.Len() >= ColN);
29  int i, j, len; TFlt *ResV = Result.BegI();
30  for (j = 0; j < ColN; j++) {
31  const TIntFltKdV& ColV = ColSpVV[j];
32  len = ColV.Len(); ResV[j] = 0.0;
33  for (i = 0; i < len; i++) {
34  ResV[j] += ColV[i].Dat * B(ColV[i].Key, ColId);
35  }
36  }
37 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
Definition: dt.h:1293
#define Assert(Cond)
Definition: bd.h:251
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:565
int GetRows() const
Definition: ds.h:2186
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
void TSparseColMatrix::PMultiplyT ( const TFltV Vec,
TFltV Result 
) const
protectedvirtual

Implements TMatrix.

Definition at line 39 of file linalg.cpp.

39  {
40  Assert(Vec.Len() >= RowN && Result.Len() >= ColN);
41  int i, j, len; TFlt *VecV = Vec.BegI(), *ResV = Result.BegI();
42  for (j = 0; j < ColN; j++) {
43  const TIntFltKdV& ColV = ColSpVV[j];
44  len = ColV.Len(); ResV[j] = 0.0;
45  for (i = 0; i < len; i++) {
46  ResV[j] += ColV[i].Dat * VecV[ColV[i].Key];
47  }
48  }
49 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
Definition: dt.h:1293
#define Assert(Cond)
Definition: bd.h:251
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:565
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
void TSparseColMatrix::Save ( TSOut SOut)
inline

Definition at line 81 of file linalg.h.

81  {
82  SOut.Save(RowN); SOut.Save(ColN); ColSpVV.Save(SOut); }
TVec< TIntFltKdV > ColSpVV
Definition: linalg.h:60
void Save(const bool &Bool)
Definition: fl.h:173

Member Data Documentation

int TSparseColMatrix::ColN

Definition at line 58 of file linalg.h.

TVec<TIntFltKdV> TSparseColMatrix::ColSpVV

Definition at line 60 of file linalg.h.

int TSparseColMatrix::RowN

Definition at line 58 of file linalg.h.


The documentation for this class was generated from the following files: