|
SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <linalg.h>
Static Public Member Functions | |
| static void | SaveCsvTFltV (const TFltV &Vec, TSOut &SOut) |
| static void | SaveMatlabTFltIntKdV (const TIntFltKdV &SpV, const int &ColN, TSOut &SOut) |
| static void | SaveMatlabTFltV (const TFltV &m, const TStr &FName) |
| static void | SaveMatlabTIntV (const TIntV &m, const TStr &FName) |
| static void | SaveMatlabTFltVVCol (const TFltVV &m, int ColId, const TStr &FName) |
| static void | SaveMatlabTFltVV (const TFltVV &m, const TStr &FName) |
| static void | SaveMatlabTFltVVMjrSubMtrx (const TFltVV &m, int rowN, int colN, const TStr &FName) |
| static void | LoadMatlabTFltVV (const TStr &FNm, TVec< TFltV > &ColV) |
| static void | LoadMatlabTFltVV (const TStr &FNm, TFltVV &MatrixVV) |
| static void | PrintTFltV (const TFltV &Vec, const TStr &VecNm) |
| static void | PrintTFltVV (const TFltVV &A, const TStr &MatrixNm) |
| static void | PrintTIntV (const TIntV &Vec, const TStr &VecNm) |
| static void | FillRnd (TFltV &Vec) |
| static void | FillRnd (TFltV &Vec, TRnd &Rnd) |
| static void | Fill (TFltVV &M, const double &Val) |
| static void | FillZero (TFltV &Vec) |
| static void | FillZero (TFltVV &M) |
| static void | FillIdentity (TFltVV &M) |
| static void | FillIdentity (TFltVV &M, const double &Elt) |
| static int | SumVec (const TIntV &Vec) |
| static double | SumVec (const TFltV &Vec) |
| static void | ToSpVec (const TFltV &Vec, TIntFltKdV &SpVec, const double &CutWordWgtSumPrc=0.0) |
| static void | ToVec (const TIntFltKdV &SpVec, TFltV &Vec, const int &VecLen) |
| static void TLAMisc::Fill | ( | TFltVV & | M, |
| const double & | Val | ||
| ) | [static] |
| void TLAMisc::FillIdentity | ( | TFltVV & | M | ) | [static] |
| void TLAMisc::FillIdentity | ( | TFltVV & | M, |
| const double & | Elt | ||
| ) | [static] |
| static void TLAMisc::FillRnd | ( | TFltV & | Vec | ) | [inline, static] |
| void TLAMisc::FillRnd | ( | TFltV & | Vec, |
| TRnd & | Rnd | ||
| ) | [static] |
Definition at line 1735 of file linalg.cpp.
| static void TLAMisc::FillZero | ( | TFltV & | Vec | ) | [inline, static] |
| static void TLAMisc::FillZero | ( | TFltVV & | M | ) | [inline, static] |
| void TLAMisc::LoadMatlabTFltVV | ( | const TStr & | FNm, |
| TVec< TFltV > & | ColV | ||
| ) | [static] |
Definition at line 1660 of file linalg.cpp.
{
PSIn SIn = TFIn::New(FNm);
TILx Lx(SIn, TFSet()|iloRetEoln|iloSigNum|iloExcept);
int Row = 0, Col = 0; ColV.Clr();
Lx.GetSym(syFlt, syEof, syEoln);
//printf("%d x %d\r", Row, ColV.Len());
while (Lx.Sym != syEof) {
if (Lx.Sym == syFlt) {
if (ColV.Len() > Col) {
IAssert(ColV[Col].Len() == Row);
ColV[Col].Add(Lx.Flt);
} else {
IAssert(Row == 0);
ColV.Add(TFltV::GetV(Lx.Flt));
}
Col++;
} else if (Lx.Sym == syEoln) {
IAssert(Col == ColV.Len());
Col = 0; Row++;
if (Row%100 == 0) {
//printf("%d x %d\r", Row, ColV.Len());
}
} else {
Fail;
}
Lx.GetSym(syFlt, syEof, syEoln);
}
//printf("\n");
IAssert(Col == ColV.Len() || Col == 0);
}
| void TLAMisc::LoadMatlabTFltVV | ( | const TStr & | FNm, |
| TFltVV & | MatrixVV | ||
| ) | [static] |
Definition at line 1691 of file linalg.cpp.
{
TVec<TFltV> ColV; LoadMatlabTFltVV(FNm, ColV);
if (ColV.Empty()) { MatrixVV.Clr(); return; }
const int Rows = ColV[0].Len(), Cols = ColV.Len();
MatrixVV.Gen(Rows, Cols);
for (int RowN = 0; RowN < Rows; RowN++) {
for (int ColN = 0; ColN < Cols; ColN++) {
MatrixVV(RowN, ColN) = ColV[ColN][RowN];
}
}
}
| void TLAMisc::PrintTFltV | ( | const TFltV & | Vec, |
| const TStr & | VecNm | ||
| ) | [static] |
Definition at line 1704 of file linalg.cpp.
| void TLAMisc::PrintTFltVV | ( | const TFltVV & | A, |
| const TStr & | MatrixNm | ||
| ) | [static] |
| void TLAMisc::PrintTIntV | ( | const TIntV & | Vec, |
| const TStr & | VecNm | ||
| ) | [static] |
Definition at line 1725 of file linalg.cpp.
| void TLAMisc::SaveCsvTFltV | ( | const TFltV & | Vec, |
| TSOut & | SOut | ||
| ) | [static] |
| void TLAMisc::SaveMatlabTFltIntKdV | ( | const TIntFltKdV & | SpV, |
| const int & | ColN, | ||
| TSOut & | SOut | ||
| ) | [static] |
Definition at line 1595 of file linalg.cpp.
| void TLAMisc::SaveMatlabTFltV | ( | const TFltV & | m, |
| const TStr & | FName | ||
| ) | [static] |
Definition at line 1602 of file linalg.cpp.
{
PSOut out = TFOut::New(FName);
const int RowN = m.Len();
for (int RowId = 0; RowId < RowN; RowId++) {
out->PutStr(TFlt::GetStr(m[RowId], 20, 18));
out->PutCh('\n');
}
out->Flush();
}
| void TLAMisc::SaveMatlabTFltVV | ( | const TFltVV & | m, |
| const TStr & | FName | ||
| ) | [static] |
Definition at line 1633 of file linalg.cpp.
{
PSOut out = TFOut::New(FName);
const int RowN = m.GetRows();
const int ColN = m.GetCols();
for (int RowId = 0; RowId < RowN; RowId++) {
for (int ColId = 0; ColId < ColN; ColId++) {
out->PutStr(TFlt::GetStr(m(RowId,ColId), 20, 18));
out->PutCh(' ');
}
out->PutCh('\n');
}
out->Flush();
}
| void TLAMisc::SaveMatlabTFltVVCol | ( | const TFltVV & | m, |
| int | ColId, | ||
| const TStr & | FName | ||
| ) | [static] |
Definition at line 1622 of file linalg.cpp.
{
PSOut out = TFOut::New(FName);
const int RowN = m.GetRows();
for (int RowId = 0; RowId < RowN; RowId++) {
out->PutStr(TFlt::GetStr(m(RowId,ColId), 20, 18));
out->PutCh('\n');
}
out->Flush();
}
| void TLAMisc::SaveMatlabTFltVVMjrSubMtrx | ( | const TFltVV & | m, |
| int | rowN, | ||
| int | colN, | ||
| const TStr & | FName | ||
| ) | [static] |
Definition at line 1647 of file linalg.cpp.
{
PSOut out = TFOut::New(FName);
for (int RowId = 0; RowId < RowN; RowId++) {
for (int ColId = 0; ColId < ColN; ColId++) {
out->PutStr(TFlt::GetStr(m(RowId,ColId), 20, 18)); out->PutCh(' ');
}
out->PutCh('\n');
}
out->Flush();
}
| void TLAMisc::SaveMatlabTIntV | ( | const TIntV & | m, |
| const TStr & | FName | ||
| ) | [static] |
Definition at line 1612 of file linalg.cpp.
| int TLAMisc::SumVec | ( | const TIntV & | Vec | ) | [static] |
Definition at line 1759 of file linalg.cpp.
{
const int Len = Vec.Len();
int res = 0;
for (int i = 0; i < Len; i++)
res += Vec[i];
return res;
}
| double TLAMisc::SumVec | ( | const TFltV & | Vec | ) | [static] |
Definition at line 1767 of file linalg.cpp.
{
const int Len = Vec.Len();
double res = 0.0;
for (int i = 0; i < Len; i++)
res += Vec[i];
return res;
}
| void TLAMisc::ToSpVec | ( | const TFltV & | Vec, |
| TIntFltKdV & | SpVec, | ||
| const double & | CutWordWgtSumPrc = 0.0 |
||
| ) | [static] |
Definition at line 1775 of file linalg.cpp.
{
// determine minimal element value
IAssert(0.0 <= CutSumPrc && CutSumPrc <= 1.0);
const int Elts = Vec.Len();
double EltSum = 0.0;
for (int EltN = 0; EltN < Elts; EltN++) {
EltSum += TFlt::Abs(Vec[EltN]); }
const double MnEltVal = CutSumPrc * EltSum;
// create sparse vector
SpVec.Clr();
for (int EltN = 0; EltN < Elts; EltN++) {
if (TFlt::Abs(Vec[EltN]) > MnEltVal) {
SpVec.Add(TIntFltKd(EltN, Vec[EltN]));
}
}
SpVec.Pack();
}
| void TLAMisc::ToVec | ( | const TIntFltKdV & | SpVec, |
| TFltV & | Vec, | ||
| const int & | VecLen | ||
| ) | [static] |
Definition at line 1795 of file linalg.cpp.