当前位置: 首页>>代码示例>>C++>>正文


C++ vec::dot方法代码示例

本文整理汇总了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;
}
开发者ID:medgno,项目名称:silmaril,代码行数:12,代码来源:Phong.cpp

示例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;
}
开发者ID:medgno,项目名称:silmaril,代码行数:14,代码来源:Phong.cpp

示例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;
}
开发者ID:besacier,项目名称:multivec,代码行数:25,代码来源:monolingual.cpp

示例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));
 }
开发者ID:Happy-Ferret,项目名称:Platinum-Arts-Sandbox-Free-Game-Maker,代码行数:10,代码来源:grass.cpp

示例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;
}
开发者ID:luaman,项目名称:sauer-cvs,代码行数:10,代码来源:geom.cpp

示例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;

}
开发者ID:Jorjor70,项目名称:meuh,代码行数:21,代码来源:test_qp.cpp

示例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;
}
开发者ID:besacier,项目名称:multivec,代码行数:38,代码来源:monolingual.cpp

示例8: dot

inline double dot(const vec&a, const vec& b){
  return a.dot(b);
}
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:3,代码来源:eigen_wrapper.hpp


注:本文中的vec::dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。