-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
90 lines (66 loc) · 1.37 KB
/
common.h
File metadata and controls
90 lines (66 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <cstring>
#include <iostream>
#include <omp.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include "time.h"
#include <cfloat>
#include <climits>
#include <unordered_set>
#include <random>
#include <windows.h>
#include <cctype>
#include<functional>
using namespace std;
FILE* fopen_(const char* p, const char* m);
typedef struct vote
{
int user;
int item;
int label;
long long voteTime;
} vote;
inline double inner(double* x, double* y, int K)
{
double res = 0;
for (int k = 0; k < K; k++)
{
res += x[k] * y[k];
}
return res;
}
inline double square(double x)
{
return x * x;
}
inline double dsquare(double x)
{
return 2 * x;
}
inline double sigmoid(double x)
{
return 1.0 / (1.0 + exp(-x));
}
static inline string <rim(string &s)
{
s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
return s;
}
static inline string &rtrim(string &s)
{
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
return s;
}
static inline string &trim(string &s)
{
return ltrim(rtrim(s));
}
void SplitString(const std::string& s, std::vector<std::string>& v, const std::string& c);