daxpy_.cpp
来自「最大熵 等模型使用的 lbfgs 训练源代码。」· C++ 代码 · 共 26 行
CPP
26 行
#include <iostream>#include <stdlib.h>#include "lbfgs.h"/* Compute the sum of a vector times a scalar plus another vector. Concretely speacking, it computes four relative weights at one time.*/void main(){ double x[10]={1,2,3,4,5,6,7,8,9,10}; double y[10]={-1,-2,-3,-4,-5,-6,-7,-8,-9,-10}; std::cout<<"vector starts at first position and shifts with 1 step length"<<std::endl; scitbx::lbfgs::detail::daxpy<double,int>(10,0.1,x,0,y); for(int i=0;i<10;++i) std::cout<<y[i]<<" "; std::cout<<std::endl; std::cout<<"vector starts at first position and shifts with 2 step length"<<std::endl; scitbx::lbfgs::detail::daxpy<double,int>(5,0.1,x,0,2,y,0,2); for(int i=0;i<10;++i) std::cout<<y[i]<<" "; std::cout<<std::endl; std::cout<<"vector starts at third position and shifts with 1 step length"<<std::endl; scitbx::lbfgs::detail::daxpy<double,int>(7,0.1,x,3,1,y,3,1); for(int i=0;i<10;++i) std::cout<<y[i]<<" "; std::cout<<std::endl;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?