#include "mtl/mtl.h"
#include "mtl/utils.h"
#include "mtl/linalg_vec.h"
/*
Sample Output
[1,2,3,]
[3,0,-1,]
Vectors x and y are orthogonal.
*/
using namespace mtl;
using namespace std;
int
main()
{
//begin
const int N = 3;
double dx[] = { 1, 2, 3};
double dy[] = { 3, 0, -1};
typedef external_vec<double> Vec;
Vec x(dx,N), y(dy,N);
print_vector(x);
print_vector(y);
double dotprd = dot(x, y);
if (dotprd == 0)
cout << "Vectors x and y are orthogonal." << endl;
else
cout << "dot(x,y) = " << dotprd << endl;
//end
return 0;
}
#include "mtl/utils.h"
#include "mtl/linalg_vec.h"
/*
Sample Output
[1,2,3,]
[3,0,-1,]
Vectors x and y are orthogonal.
*/
using namespace mtl;
using namespace std;
int
main()
{
//begin
const int N = 3;
double dx[] = { 1, 2, 3};
double dy[] = { 3, 0, -1};
typedef external_vec<double> Vec;
Vec x(dx,N), y(dy,N);
print_vector(x);
print_vector(y);
double dotprd = dot(x, y);
if (dotprd == 0)
cout << "Vectors x and y are orthogonal." << endl;
else
cout << "dot(x,y) = " << dotprd << endl;
//end
return 0;
}
此博客给出一段代码,通过包含多个头文件,定义两个向量 x 和 y,计算它们的点积。若点积为 0,则判定两向量正交,否则输出点积值,展示了向量正交性的判断方法。
712

被折叠的 条评论
为什么被折叠?



