本文整理汇总了C++中vec::dot方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::dot方法的具体用法?C++ vec::dot怎么用?C++ vec::dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::dot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdf
double Phong::pdf(const vec& incoming, const vec& direction, const vec& normal) {
//vec newDirection = direction;
//newDirection.normalize();
if (normal.dot(direction) < 0)
return 0;
vec reflect = normal * (2 * normal.dot(incoming * -1)) + incoming;
double ans = (exp) * pow(reflect.dot(direction * -1), exp);
if (ans < 0)
return 0;
else
return ans * BOUNCE_MULT;
}
示例2: sample
vec Phong::sample(const vec& incoming, const vec& normal) {
//No meaning to the following vector. Only purpose is that we usually won't be parallel
// to it.
vec reflect = normal * (2 * normal.dot(incoming * -1)) + (incoming);
vec u = reflect.cross(vec(0.973483, 0.228749, 0.00225264,0));
u.normalize();
vec v = reflect.cross(u);
v.normalize();
vec r = Random::randomCosVec(exp);
vec ans = u * r[0] + v * r[1] + reflect * r[2];
if (normal.dot(ans) < 0)
ans = normal * (2 * normal.dot(ans)) - ans;
return ans;
}
示例3: hierarchicalUpdate
vec MonolingualModel::hierarchicalUpdate(const HuffmanNode& node, const vec& hidden,
float alpha, bool update) {
int dimension = config.dimension;
vec temp(dimension, 0);
for (int j = 0; j < node.code.size(); ++j) {
int parent_index = node.parents[j];
float x = hidden.dot(output_weights_hs[parent_index]);
if (x <= -MAX_EXP || x >= MAX_EXP) {
continue;
}
float pred = sigmoid(x);
float error = -alpha * (pred - node.code[j]);
temp += error * output_weights_hs[parent_index];
if (update && !config.freeze) {
output_weights_hs[parent_index] += error * hidden;
}
}
return temp;
}
示例4: grasswedge
grasswedge(int i) :
dir(2*M_PI*(i+0.5f)/float(NUMGRASSWEDGES), 0),
across(2*M_PI*((i+0.5f)/float(NUMGRASSWEDGES) + 0.25f), 0),
edge1(vec(2*M_PI*i/float(NUMGRASSWEDGES), 0).div(cos(M_PI/NUMGRASSWEDGES))),
edge2(vec(2*M_PI*(i+1)/float(NUMGRASSWEDGES), 0).div(cos(M_PI/NUMGRASSWEDGES))),
bound1(vec(2*M_PI*(i/float(NUMGRASSWEDGES) - 0.25f), 0), 0),
bound2(vec(2*M_PI*((i+1)/float(NUMGRASSWEDGES) + 0.25f), 0), 0)
{
across.div(-across.dot(bound1));
}
示例5: raysphereintersect
bool raysphereintersect(vec c, float radius, const vec &o, const vec &ray, float &dist)
{
c.sub(o);
float v = c.dot(ray),
inside = radius*radius - c.squaredlen(),
d = inside + v*v;
if(inside<0 && d<0) return false;
dist += v - sqrt(d);
return true;
}
示例6: results
void results(const mat& Q, const vec& c,
const mat& A, const vec& b,
const vec& x,
vec reference = vec()) {
// std::cout << "solution: " << x.transpose() << std::endl;
using namespace std;
const math::natural m = c.rows();
const math::natural n = b.rows();
cout << "violation: " << (A * x - b).cwiseMin( vec::Zero(n) ).squaredNorm() / m << endl;
cout << "obj: " << x.dot( 0.5 * (Q * x) + c ) << endl;
if(!reference.empty()) {
core::log("error:", (x - reference).norm() );
}
cout << endl;
}
示例7: negSamplingUpdate
vec MonolingualModel::negSamplingUpdate(const HuffmanNode& node, const vec& hidden, float alpha, bool update) {
int dimension = config.dimension;
vec temp(dimension, 0);
for (int d = 0; d < config.negative + 1; ++d) {
int label;
const HuffmanNode* target;
if (d == 0) { // 1 positive example
target = &node;
label = 1;
} else { // n negative examples
target = getRandomHuffmanNode();
if (*target == node) continue;
label = 0;
}
float x = hidden.dot(output_weights[target->index]);
float pred;
if (x >= MAX_EXP) {
pred = 1;
} else if (x <= -MAX_EXP) {
pred = 0;
} else {
pred = sigmoid(x);
}
float error = alpha * (label - pred);
temp += error * output_weights[target->index];
if (update && !config.freeze) {
output_weights[target->index] += error * hidden;
}
}
return temp;
}
示例8: dot
inline double dot(const vec&a, const vec& b){
return a.dot(b);
}