My Project
|
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <utility>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include "Vector3.h"
#include "DDLinkedList.h"
#include "Const.h"
#include "/Users/aaa/myfile/bitbucket/clib/AronCLibNew.h"
#include <vector>
#include "glm/glm/glm.hpp"
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
#include <regex>
#include <algorithm>
#include <cctype>
#include <locale>
#include <limits>
#include <stdexcept>
#include <array>
#include <boost/filesystem.hpp>
Go to the source code of this file.
Classes | |
class | StopWatch |
class | two< T, U > |
class | AronGeometry::Point< T > |
class | AronGeometry::Pair< T > |
class | AronGeometry::Vector< T > |
class | AronGeometry::Segment< T > |
class | SpaceComplex::Complex |
class | MatrixVector::vec |
class | MatrixVector::row |
class | MatrixVector::mat |
class | MatrixVector::mat::Loader |
Inspired from Eigen Lib. More... | |
class | SpaceVector4::Vector4 |
Namespaces | |
namespace | Utility |
many function can be global actually | |
namespace | Complex |
complex number representation and operation number | |
namespace | MatrixVector |
Two dimensional array represents matrix, column and row vector. | |
namespace | SpaceVector4 |
4 dimensions vector | |
namespace | Algorithm |
include all the sorting algorithms etc. | |
Functions | |
int | len (string s) |
length of string | |
template<typename T > | |
int | len (vector< T > v) |
length of vector | |
template<typename T > | |
string | toStr (const T &s) |
Convert any type to std::string. | |
template<typename T > | |
string | toStr2 (T &s) |
template<typename T > | |
string | toStrVar (T &s) |
template<typename T > | |
vector< vector< T > > | transpose (vector< vector< T > > mat) |
transpose matrix | |
template<typename T > | |
bool | compareVector (vector< T > v1, vector< T > v2) |
template<typename T > | |
bool | compareVector (vector< vector< T > > v1, vector< vector< T > > v2) |
template<typename T > | |
vector< vector< T > > | arrToVec2 (T *arr, int len, int width) |
void | printArr2 (float *arr, int len, int width) |
int | unsignToInt (size_t u) |
string | padRight (string s, string pad, int maxLen) |
string | padLeft (string s, string pad, int maxLen) |
template<typename T > | |
two< T, T > | divMod (T a, T b) |
void | newline () |
void | nl () |
int | max (int a, int b, int c) |
int | max (int a, int b, int c, int d) |
int | max (vector< int > v) |
string | reverseStr (string s) |
int | maxConsecutiveOne (vector< int > vec) |
int | strToInt (string s) |
int | numFromBase (string fromBase, string input) |
vector< int > | range (int a, int b) |
vector< int > | range (int a, int b, int stride) |
template<typename T > | |
vector< T > | reverseVec (vector< T > vec) |
std::map< char, int > | hexMap () |
string | baseToBase (string fromBase, string toBase, string input) |
uint64_t | nowMilliseconds () |
uint64_t | nowMicroseconds () |
uint64_t | nowNanoseconds () |
template<typename T > | |
vector< T > | repeatVec (int n, T t) |
template<typename T > | |
vector< T > | concatVec (vector< T > v1, vector< T > v2) |
Concat two vectors. | |
vector< int > | randomNanoSec (int n, int max) |
template<typename T > | |
T | dotProduct (vector< T > v1, vector< T > v2) |
template<typename T > | |
T | det2 (vector< vector< T > > v2) |
template<typename T > | |
vector< T > | subtract (vector< T > v1, vector< T > v2) |
void | testfun () |
void | testfun1 () |
void | testfun2 () |
void | getTypeSize () |
int | maxConsecutiveChar (char *arr, int size, char c) |
std::map< int, char > | hexMapRev () |
vector< int > | toBinary (int n) |
int | abs_int (int a) |
float | abs_f (float a) |
long | abs_l (long a) |
long long | abs_ll (long long a) |
double | abs_d (double a) |
unsigned int | abs_ui (unsigned int a) |
template<typename T > | |
void | writeFileAppendVector (string fname, std::vector< T > vec) |
void | writeFile (string fname, string s) |
void | writeFileAppend (string fname, string s) |
template<typename T > | |
void | writeFileVector (string fname, std::vector< T > vec) |
template<typename T > | |
void | writeFileAppendRow (string fname, std::vector< T > vec) |
Write vector to file using space as delimiter. | |
std::pair< string, string > | split (string s, int inx) |
vector< int > | sumVec (vector< int > v1, vector< int > v2) |
sum two int vectors | |
string | removeIndex (string s, int inx) |
remove char from a string | |
template<typename T > | |
vector< T > | removeIndex (vector< T > &vec, int inx) |
remove an index from a vector | |
template<typename T > | |
vector< T > | removeIndexRange (vector< T > &vec, int fromInx, int toInx) |
remove index from to index inclusively. | |
string | repeat (int n, string s) |
Repeating n copy of s. The function is inspired by Haskell repeat. | |
string | cStringToString (const char *pt) |
char* to string | |
template<typename T > | |
void | pl (T t) |
void | print (glm::vec3 v3) |
void | print (glm::vec2 v2) |
string | removeAdjacentDuplicateChar (string s, char c) |
remove adjacent duplicate char from a string | |
string | concatValidPath (vector< string > vec) |
remove adjacent duplicate char from a string | |
template<typename T > | |
void | print (std::pair< T, T > pair) |
template<typename T > | |
void | print (vector< T > vec) |
template<typename T > | |
void | printVec (vector< T > vec) |
template<typename T > | |
void | print (vector< vector< T > > vec) |
template<typename T > | |
void | print (T t) |
template<typename T > | |
void | print (string msg, T t) |
template<typename T > | |
void | printLnNb (T t) |
template<typename T > | |
vector< T > | operator+ (vector< T > v1, vector< T > v2) |
Concate two vectors, both vectors are NOT modified. | |
string | operator+ (const char *chars, string s) |
string | operator+ (string s, const char *chars) |
template<typename T > | |
vector< T > | con (T t, vector< T > v) |
void | AronPrint::ppf (const char *format,...) |
void | AronPrint::fw (string s) |
template<typename T > | |
void | AronPrint::pp (T t) |
template<typename T > | |
void | AronPrint::pp (T t1, T t2) |
template<typename T > | |
void | AronPrint::pp (T t1, T t2, T t3) |
template<typename T , typename U > | |
void | AronPrint::pp (std::pair< T, U > p) |
void | AronPrint::pp (int n) |
void | AronPrint::pp (float n) |
void | AronPrint::pp (long n) |
void | AronPrint::pp (unsigned long n) |
void | AronPrint::pp (string msg0, string msg1) |
void | AronPrint::pp (string msg0, float num) |
void | AronPrint::pp (string msg0, int num) |
void | AronPrint::pp (string msg0, long num) |
void | AronPrint::pp (string msg0, double num) |
void | AronPrint::pp (string msg0, char *charPt) |
void | AronPrint::fl (string s) |
template<typename T > | |
T | AronLambda::head (vector< T > vec) |
char | AronLambda::head (string s) |
template<typename T > | |
T | AronLambda::last (vector< T > vec) |
template<typename T > | |
void | swap (vector< T > &vec, int i, int j) |
int | random (int n) |
random number from 0 to n-1 NOTE: Ubuntu DOES NOT have arc4random_uniform, it works on MacOS only. | |
template<typename T > | |
void | swap (T arr[], int i, int j) |
long | lcgRandom (long x0) |
Linear congruential generator. | |
vector< int > | randomIntVec (int count, int max) |
vector< int > | allPrime (int n) |
vector< int > * | nPrime (int n) |
const char * | stringToCString (string s) |
Convert std::string to char*, same as s2c(string s) | |
const char * | s2c (string s) |
Convert std::string to char*. | |
const char * | toCharPtr (string s) |
it is same as s2c but it is better name. | |
const char * | strToCharArray (string s) |
template<typename T , typename U > | |
string | toStr (std::pair< T, U > p) |
template<typename T , typename U > | |
string | str (std::pair< T, U > p) |
template<typename T > | |
string | str (const T &s) |
template<typename T > | |
string | str2 (T &s) |
string | trimLeft (string str) |
string | trimRight (string str) |
string | trim (string str) |
trim both ends | |
string | charPtrToString (const char *pt) |
string | c2s (const char *pt) |
string to char* | |
bool | containStrRegex (string s, regex rx) |
check s contains regex pattern | |
bool | containStr (string str, string pat) |
check if str contain pat | |
vector< string > | splitStr (string s, string delim) |
Split string with delimiter. | |
template<typename T > | |
std::pair< vector< T >, vector< T > > | splitAt (int n, vector< T > vec) |
split vector to pair of vector | |
template<typename Fun , typename T > | |
std::pair< vector< T >, vector< T > > | breakVec (Fun f, vector< T > vec) |
break a vector to pair | |
template<typename T > | |
vector< T > | replaceVec (T oldVal, T newVal, vector< T > vec) |
replace oldVale with newVal in a cloned vector | |
template<typename T > | |
vector< T > | insertAt (vector< T > vec, int pos, vector< T > insertVec) |
Insert vector @insertVec into vec at position @pos. | |
vector< std::string > | splitStrRegex (const string &s, string rgxStr="\\s+") |
Split string with regex. | |
bool | isEmpty (string s) |
bool | isEmpty (const char *cpt) |
double | squareRoot (double a) |
double | intToDouble (int n) |
double | nthRoot (double c, int n, double epsilon=0.000001) |
Compute the nth root of any positive integer, n >= 1. | |
string | charArrToString (const char *pt) |
string | replicate (int n, string s) |
template<typename T > | |
void | add (vector< T > &vec, T t) |
int | compareCString (char *s1, char *s2) |
int | compareString (string s1, string s2) |
bool | compareFloat (double a, double b) |
void | printLn (glm::vec3 v3) |
void | printLn (glm::vec2 v2) |
string | toString (glm::vec3 v3) |
int | inx (int cIx, int rIx, int width) |
void | tranmat4 (float arr[16]) |
template<typename T > | |
bool | compareArray (T arr1[], T arr2[], const int s1) |
template<typename T > | |
void | print (two< T, T > t) |
template<typename T > | |
void | printNb (T t) |
print no bracket | |
template<typename T > | |
void | printLn (T t) |
template<typename T > | |
void | ppL (T t) |
void | printArr (float arr[10], int n, int nCol) |
template<typename T > | |
vector< T > * | moveVec (T a, vector< T > vec) |
use std::move, it acts like Java. Create local object, and return it. | |
template<typename T > | |
vector< T > * | append (vector< T > vec, T a) |
use std::move, it acts like Java. Create local object, and return it. | |
int | length (string s) |
length of string | |
template<typename T > | |
int | length (vector< T > v) |
length of vector | |
template<typename T > | |
bool | binSearch (T key, T arr[], int lo, int hi) |
binary search on a sorted array | |
template<typename T > | |
vector< T > | operator* (T a, vector< T > vec) |
scalar multiply vector | |
template<typename T > | |
vector< T > | operator* (vector< T > vec, T a) |
scalar multiply vector | |
template<typename T > | |
vector< vector< T > > | operator* (T a, vector< vector< T > > vec2) |
template<typename T > | |
vector< vector< T > > | operator* (vector< vector< T > > vec2, T a) |
vector< int > | geneVector (int a, int b) |
bool | isBST (Node< int > *curr, Node< int > *&prev) |
Check whether a Binary Tree is BST. | |
template<typename T > | |
vector< vector< T > > | geneMatrix (int ncol, int nrow, T init) |
Generate ncol x nrow matrix with initial value @init. | |
template<typename T > | |
void | swapT (T array[], int i, int j) |
template<typename T > | |
int | partitionT (T array[], int lo, int hi) |
partition array inline | |
template<typename T > | |
T | partition (vector< T > &vec, int lo, int hi) |
partition vector, use [hi] as pivot, like in quicksort | |
template<typename T > | |
int | partitionInline (vector< T > &vec, int lo, int hi) |
partition vector inline | |
template<typename T > | |
void | quickSortVec (vector< T > &vec, int lo, int hi) |
template<typename T > | |
void | quickSortT (T array[], int lo, int hi) |
std::string | replace (std::string str, regex rex, std::string rep) |
bool | isEmptyLine (string s) |
string | getEnv (string env) |
template<typename T > | |
vector< T > | getCol (int ix, vector< vector< T > > v) |
template<class T = double> | |
double | AronGeometry::isColinear3 (Point< T > p, Point< T > p1, Point< T > p2) |
template<class T = double> | |
bool | AronGeometry::isCrossSegment (Point< T > p0, Point< T > p1) |
bool | Utility::isSubstring (string sub, string s) |
Check whether sub is the substring of s. | |
int | Utility::substringFirstIndex (string sub, string s) |
find the index of sub in string s | |
string | Utility::fun_parent_parent () |
void | Utility::cut (char *pt) |
int | Utility::stringToInt (string s) |
double | Utility::stringToDouble (std::string s) |
long | Utility::stringToLong (std::string s) |
float | Utility::stringToFloat (std::string s) |
string | Utility::charToString (char ch) |
void | Utility::begin () |
void | Utility::begin (const char *name) |
void | Utility::end () |
string | Utility::fun_parent () |
void | Utility::print (Vector3 v) |
void | Utility::print (DDLinkedList< Vector3 > *ddl) |
Complex | SpaceComplex::rectangular (std::pair< double, double > p) |
template<typename T > | |
T ** | MatrixVector::allocateTemp (int ncol, int nrow) |
Allocate ncol, nrow two dimension array for any type, return a pointer. | |
template<typename T > | |
T ** | MatrixVector::allocate (int ncol, int nrow) |
Allocate a matrix: height = ncol, width = nrow. | |
template<typename T > | |
T ** | MatrixVector::vecVecToArrArr (vector< vector< T > > vv) |
Convert Vector< Vector<T> > to dynamic T**. | |
template<typename T > | |
vector< vector< T > > | MatrixVector::arrArrToVecVec (T **arr, int ncol, int nrow) |
Convert T** arr to vector<vector<T>> v2. | |
mat | MatrixVector::concat (mat m1, mat m2) |
mat | MatrixVector::identity (int n) |
vec | MatrixVector::backwardSubstitute (mat a, vec b) |
Backward Substitute. | |
mat | MatrixVector::ltri (mat m, int index) |
Get the L triangle from a matrix. | |
std::pair< mat, mat > | MatrixVector::utri (mat m) |
Assume the diagonal entries are not zero, compute the U triangle matrix Lk..(L2 (L1 A))= U TODO: fix the code if a_{ii} = 0. | |
mat | MatrixVector::geneMat (int ncol, int nrow, int init) |
mat | MatrixVector::geneMatRandom (int ncol, int nrow, int fst, int snd) |
Generate random matrix in interval from fst to snd. | |
void | Algorithm::merge (int *arr, int lo, int mid, int hi) |
void | Algorithm::mergeSort (int *arr, int lo, int hi) |
void | Algorithm::swap (int array[], int i, int j) |
int | Algorithm::partition (int array[], int lo, int hi) |
partition array to to left and right, using [hi] as pivot | |
void | Algorithm::quickSortArr (int array[], int lo, int hi) |
void | writeFile (string fname, mat &m) |
template<class T > | |
T | det2 (vector< T > v1, vector< T > v2) |
template<class T > | |
vector< T > | crossProduct (vector< T > v1, vector< T > v2) |
vector< T > * append | ( | vector< T > | vec, |
T | a | ||
) |
use std::move, it acts like Java. Create local object, and return it.
Better name
bool binSearch | ( | T | key, |
T | arr[], | ||
int | lo, | ||
int | hi | ||
) |
binary search on a sorted array
k = 4 1 1 2 2 4 x 2 4 x 4 t
std::pair< vector< T >, vector< T > > breakVec | ( | Fun | f, |
vector< T > | vec | ||
) |
break a vector to pair
int compareCString | ( | char * | s1, |
char * | s2 | ||
) |
compare char* char* return n < 0, n == 0, n > 0
bool compareFloat | ( | double | a, |
double | b | ||
) |
compare float float
int compareString | ( | string | s1, |
string | s2 | ||
) |
compare string string return n < 0, n == 0, n > 0
string concatValidPath | ( | vector< string > | vec | ) |
remove adjacent duplicate char from a string
LINE: concatValidPath({"a", "b"}) => a/b
LINE: concatValidPath({"a", "b"}) => a/b
bool containStr | ( | string | str, |
string | pat | ||
) |
check if str contain pat
bool containStrRegex | ( | string | s, |
regex | rx | ||
) |
check s contains regex pattern
vector< T > crossProduct | ( | vector< T > | v1, |
vector< T > | v2 | ||
) |
KEY: cross product of two vectors
Cofactor expension
v1 = x0 y0 z0
v2 = x1 y1 z1
i j k x0 y0 z0 x1 y1 z1
v1 ⨂ v2 = (-1)^1+1 i |y0 z0| |y1 z1| + (-1)^1+2 j |x0 z0| |x1 z1| + (-1)^1+3 k |x0 y0| |x1 y1|
string cStringToString | ( | const char * | pt | ) |
char* to string
KEY: char* to string, char array to string, char* to string, char pt to string
KEY: char* to string, char array to string, char* to string, char pt to string
T det2 | ( | vector< T > | v1, |
vector< T > | v2 | ||
) |
KEY: determinant of two by two matrix A = a b <- v1 c d <- v2
det(A) = ad - bc
vector<vector<float>> v2 = {{1, 2}, {3, 4} }; float n = det2(v2); printf("n=%f\n", n);
T det2 | ( | vector< vector< T > > | v2 | ) |
KEY: determinant of two by two matrix A = a b c d
det(A) = ad - bc
vector<vector<float>> v2 = {{1, 2}, {3, 4} }; float n = det2(v2); printf("n=%f\n", n);
T dotProduct | ( | vector< T > | v1, |
vector< T > | v2 | ||
) |
KEY: dot product of two vectors
vector<float> v1 = {1, 2, 3}; vector<float> v2 = {1, 2, 3}; float n = dotProduct(v1, v2); printf("dotProduct=%f\n", n);
vector< vector< T > > geneMatrix | ( | int | ncol, |
int | nrow, | ||
T | init | ||
) |
Generate ncol x nrow matrix with initial value @init.
T AronLambda::head | ( | vector< T > | vec | ) |
head of vector
std::map< char, int > hexMap | ( | ) |
0 -> '0' 1 -> '1' 2 -> '2' 3 -> '3' 4 -> '4' 5 -> '5' 6 -> '6' 7 -> '7' 8 -> '8' 9 -> '9' 10 -> 'a' 11 -> 'b' 12 -> 'c' 13 -> 'd' 14 -> 'e' 15 -> 'f'
vector< T > insertAt | ( | vector< T > | vec, |
int | pos, | ||
vector< T > | insertVec | ||
) |
Insert vector @insertVec into vec at position @pos.
The original vector is NOT modified.
insert([1, 2, 3], 1, [11, 22]) => [1, 11, 22, 2, 3]
@v - original vector
@pos - position that new vector will be inserted at
@insertVec - vector will be inserted at position @pos
double intToDouble | ( | int | n | ) |
int to double
Check whether a Binary Tree is BST.
Java can not be done like that because argument can not be passed by reference in Java.
bool isEmpty | ( | const char * | cpt | ) |
check if a char* is empty
bool isEmpty | ( | string | s | ) |
check if a string is empty
T AronLambda::last | ( | vector< T > | vec | ) |
last of element in a vector if size() > 0, otherwise error
long lcgRandom | ( | long | x0 | ) |
Linear congruential generator.
NOTE: Ubuntu DOES NOT have arc4random_uniform, it works on MacOS only. https://en.wikipedia.org/wiki/Linear_congruential_generator Linear congruential generator
int maxConsecutiveChar | ( | char * | arr, |
int | size, | ||
char | c | ||
) |
KEY: find the maximum length of consecutive characters from a string
int maxConsecutiveOne | ( | vector< int > | vec | ) |
0 0 1 1 1 0 => 3
0 0 1 1 1 0 1 1 1 1 => 4
vector< T > * moveVec | ( | T | a, |
vector< T > | vec | ||
) |
use std::move, it acts like Java. Create local object, and return it.
|
inline |
uint64_t t = nowMicroseconds(); cout<<"nowMilliseconds second t="<<t<<endl;
|
inline |
uint64_t t = nowMilliseconds(); cout<<"nowMillionseconds second t="<<t<<endl;
|
inline |
uint64_t t = nowNanoseconds(); cout<<"nowNanoseconds second t="<<t<<endl;
double nthRoot | ( | double | c, |
int | n, | ||
double | epsilon = 0.000001 |
||
) |
Compute the nth root of any positive integer, n >= 1.
TODO: negative number?
vector< T > operator* | ( | T | a, |
vector< T > | vec | ||
) |
scalar multiply vector
vector< T > operator* | ( | vector< T > | vec, |
T | a | ||
) |
scalar multiply vector
vector< T > operator+ | ( | vector< T > | v1, |
vector< T > | v2 | ||
) |
Concate two vectors, both vectors are NOT modified.
T partition | ( | vector< T > & | vec, |
int | lo, | ||
int | hi | ||
) |
partition vector, use [hi] as pivot, like in quicksort
Partition with a tmp vector
int partitionInline | ( | vector< T > & | vec, |
int | lo, | ||
int | hi | ||
) |
partition vector inline
Use the inline partition, the space complexity can be O(1), like heap sort.
Partition a vector without a tmp vector
int partitionT | ( | T | array[], |
int | lo, | ||
int | hi | ||
) |
partition array inline
partition array with a [hi] = pivot
void quickSortT | ( | T | array[], |
int | lo, | ||
int | hi | ||
) |
KEY: quick sort in an array
int random | ( | int | n | ) |
random number from 0 to n-1 NOTE: Ubuntu DOES NOT have arc4random_uniform, it works on MacOS only.
vector< int > randomNanoSec | ( | int | n, |
int | max | ||
) |
Simple random number generate based on current nanosecond time
Complex SpaceComplex::rectangular | ( | std::pair< double, double > | p | ) |
TODO: add test cases
string removeAdjacentDuplicateChar | ( | string | s, |
char | c | ||
) |
remove adjacent duplicate char from a string
LINE: removeAdjacentDuplicateChar("abb", 'b') => ab
LINE: removeAdjacentDuplicateChar("abb", 'b') => ab
string removeIndex | ( | string | s, |
int | inx | ||
) |
remove char from a string
remove [inx] char from a string removeIndex("cat", 1) => "ct"
vector< T > removeIndex | ( | vector< T > & | vec, |
int | inx | ||
) |
remove an index from a vector
vector< T > removeIndexRange | ( | vector< T > & | vec, |
int | fromInx, | ||
int | toInx | ||
) |
remove index from to index inclusively.
string repeat | ( | int | n, |
string | s | ||
) |
Repeating n copy of s. The function is inspired by Haskell repeat.
vector< T > replaceVec | ( | T | oldVal, |
T | newVal, | ||
vector< T > | vec | ||
) |
replace oldVale with newVal in a cloned vector
vec is NOT modified
vector< T > reverseVec | ( | vector< T > | vec | ) |
KEY: reverse vector
vector<T> v(vec); std::reverse(v.begin(), v.end());
std::pair< vector< T >, vector< T > > splitAt | ( | int | n, |
vector< T > | vec | ||
) |
split vector to pair of vector
vector<int> vec = {1, 2, 3, 4}; splitAt(2, vec) => left side is 2 elements
splitAt(n, vec) => take(2, vec), drop(2, vec)
first = {1, 2} second = {2, 3, 4}
vector< string > splitStr | ( | string | s, |
string | delim | ||
) |
vector< std::string > splitStrRegex | ( | const string & | s, |
string | rgxStr = "\\s+" |
||
) |
Split string with regex.
@s - input string
@rgxStr - string passed into regex
https://stackoverflow.com/questions/16749069/c-split-string-by-regex
The -1 is the key here: when the iterator is constructed the iterator points at the text that precedes that match and after each increment the iterator points at the text that followed the previous match.
double squareRoot | ( | double | a | ) |
Newton' method to find the square root of any positive float point number.
const char * stringToCString | ( | string | s | ) |
Convert std::string to char*, same as s2c(string s)
KEY: string to char*
vector< T > subtract | ( | vector< T > | v1, |
vector< T > | v2 | ||
) |
subtract two vectors
vector< int > sumVec | ( | vector< int > | v1, |
vector< int > | v2 | ||
) |
sum two int vectors
GLOBAL
vector<int> v1 = {9, 2}; vector<int> v2 = {9, 4, 5}; vector<int> v3 = sumVec(v1, v2);
[9][2] [9][4][5] [1][0][3][7]
vector< int > toBinary | ( | int | n | ) |
int to binary
const char * toCharPtr | ( | string | s | ) |
it is same as s2c but it is better name.
KEY: string to char*, string to char array
string toStr | ( | const T & | s | ) |
Convert any type to std::string.
T must be overrided <<
void tranmat4 | ( | float | arr[16] | ) |
KEY: transpose float arr[16]
float arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
fl(); printArray2df(4, 4, arr);
tranmat4(arr); fl("tran"); printArray2df(4, 4, arr);
vector< vector< T > > transpose | ( | vector< vector< T > > | mat | ) |
transpose matrix
\[ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \rightarrow \begin{bmatrix} 1 & 4 & 7 \\ 2 & 5 & 8 \\ 3 & 6 & 9 \end{bmatrix} \]
string trim | ( | string | str | ) |
void writeFileAppendRow | ( | string | fname, |
std::vector< T > | vec | ||
) |
Write vector to file using space as delimiter.