eigen 教程和指南

2023-10-29

转自:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html

https://blog.csdn.net/xuezhisdc/article/details/54619853

固定大小的矩阵和向量

/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

// import most common Eigen types
int main(int, char *[])
{
    Matrix3f m3; //3x3单精度矩阵
    m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
    Matrix4f m4 = Matrix4f::Identity(); //4x4单位矩阵(单精度)
    Vector4i v4(1, 2, 3, 4); // 长度为4的整型向量

    // 输出结果
    std::cout << "m3\n" << m3 << "\nm4:\n"
        << m4 << "\nv4:\n" << v4 << std::endl;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • Matrix表示矩阵,Vector表示向量,数字表示维度,最后的f和i分别表示单精度和整型数据类型。
  • 固定大小表示编译时,行数和列数是固定的。这时,Eigen不会分配动态内存。这对于比较小的尺寸比较适合,比如16x16。

动态大小的矩阵和向量

/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    // 动态矩阵
    for (int size=1; size<=4; ++size)
    {
        MatrixXi m(size,size+1); // 一个整型的大小为 (size)x(size+1) 的矩阵
        for (int j=0; j<m.cols(); ++j) // 遍历列
            for (int i=0; i<m.rows(); ++i) // 遍历行
                m(i,j) = i+j*m.rows(); // 使用圆括号m(i,j)访问矩阵的元素
        std::cout << m << "\n\n"; //打印矩阵
    }

    // 动态向量
    VectorXf v(4); // 定义一个4维单精度向量
    // 使用圆括号()或方括号[]访问向量元素
    v[0] = 1; v[1] = 2; v(2) = 3; v(3) = 4;
    std::cout << "\nv:\n" << v << std::endl;
}
  • 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
  • 小结:X表示动态大小。
  • #include <Eigen/Eigen>将包含所有的Eigen函数。#include <Eigen/Dense>包含所有普通矩阵函数,不包括稀疏矩阵函数。它们会增加编译时间。

矩阵和向量类型

  • Eigen中的所有密集矩阵和向量都是通过Matrix类来表示的。Matrix通过一系列的模板参数来生成具体的类别。
  • Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime>中,Scalar表示数据类型,RowsAtCompileTime和ColsAtCompileTime分别表示编译时的行数和列数。
  • Vector3d 定义为 Matrix<double, 3, 1>
  • 对于动态大小的类型,在编译时不指定行数和列数,使用Eigen::Dynamic。比如,VectorXd定义为Matrix<double, Dynamic, 1>

访问元素

  • Eigen支持以下的读/写元素语法:
matrix(i,j);
vector(i)
vector[i]
vector.x() // first coefficient
vector.y() // second coefficient
vector.z() // third coefficient
vector.w() // fourth coefficient
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 矩阵只能通过圆括号()访问;
  • 向量可以通过圆括号()和方括号[]访问。
  • 上述的元素访问方法都通过断言检查范围,代价比较大。 
    • 通过定义EIGEN_NO_DEBUG 或 NDEBUG,取消断言。
    • 通过使用coeff()coeffRef(),来取消检查。比如,MatrixBase::coeff(int,int) const, MatrixBase::coeffRef(int,int)等。

创建和初始化矩阵和向量

通过预定义矩阵初始化

创建固定大小的矩阵和向量
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    float value = 3.0;
    Matrix3f x; // 创建一个3x3的单精度矩阵
    x = Matrix3f::Zero(); //全零矩阵
    cout << x << endl << endl;
    x = Matrix3f::Ones(); //全一矩阵
    cout << x << endl << endl;
    x = Matrix3f::Constant(value); //全value矩阵
    cout << x << endl << endl;
    x = Matrix3f::Identity(); //单位矩阵
    cout << x << endl << endl;
    x = Matrix3f::Random(); // 随机矩阵
    cout << x << endl << endl;
    x.setZero();
    cout << x << endl << endl;
    x.setOnes();
    cout << x << endl << endl;
    x.setIdentity();
    cout << x << endl << endl;
    x.setConstant(value);
    cout << x << endl << endl;
    x.setRandom();
    cout << x << endl << endl;
}
  • 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
创建动态大小的矩阵
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    float value = 3.0f;
    int rows = 3;
    int cols = 4;
    MatrixXf x;
    x = MatrixXf::Zero(rows, cols);
    cout << x << endl << endl;
    x = MatrixXf::Ones(rows, cols);
    cout << x << endl << endl;
    x = MatrixXf::Constant(rows, cols, value);
    cout << x << endl << endl;
    x = MatrixXf::Identity(rows, cols);
    cout << x << endl << endl;
    x = MatrixXf::Random(rows, cols);
    cout << x << endl << endl;
    x.setZero(rows, cols);
    cout << x << endl << endl;
    x.setOnes(rows, cols);
    cout << x << endl << endl;
    x.setConstant(rows, cols, value);
    cout << x << endl << endl;
    x.setIdentity(rows, cols);
    cout << x << endl << endl;
    x.setRandom(rows, cols);
    cout << x << endl << endl;
    return 0;
}
  • 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
创建动态大小的向量
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    int size = 3;
    float value = 3.0f;
    VectorXf x; // 定义动态向量
    x = VectorXf::Zero(size); //全0向量
    cout << x << endl << endl;
    x = VectorXf::Ones(size); //全1向量
    cout << x << endl << endl;
    x = VectorXf::Constant(size, value);//全value向量
    cout << x << endl << endl;
    //x = VectorXf::Identity(size);//报错
    x = VectorXf::Random(size);
    cout << x << endl << endl;
    x.setZero(size);
    cout << x << endl << endl;
    x.setOnes(size);
    cout << x << endl << endl;
    x.setConstant(size, value);
    cout << x << endl << endl;
    //x.setIdentity(size);
    x.setRandom(size);
    cout << x << endl << endl;
    return 0;
}
  • 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
创建固定大小的基向量
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    Vector3f x;
    x = Vector3f::UnitX(); // 1 0 0
    cout << x << endl << endl;
    x = Vector3f::UnitY(); // 0 1 0
    cout << x << endl << endl;
    x = Vector3f::UnitZ(); // 0 0 1
    cout << x << endl << endl;

    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
创建动态大小的基向量
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    VectorXf x;
    x = VectorXf::Unit(4,1);
    cout << x << endl << endl;
    x = Vector4f(0,1,0,0);
    cout << x << endl << endl;
    x = Vector4f::UnitY();
    cout << x << endl << endl;

    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
例子
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{

    cout << MatrixXf::Constant(2, 3, sqrt(2)) << endl; // 2x3的单精度矩阵
    RowVector3i v; //3维行向量
    v.setConstant(6);
    cout << "v = " << v << endl;

    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

通过Cast的方式初始化

相同尺寸的矩阵兼容
  • 元素类型通过MatrixBase::cast()自动转换。
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>
#include <Eigen/Eigen>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    Vector3d md(1,2,3);
    Vector3f mf = md.cast<float>();
    cout << "md = " << md << endl;
    cout << "mf = " << mf << endl;
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
相同类型的矩阵兼容
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    MatrixXf res(10,10);
    Matrix3f a, b;
    a = Matrix3f::Identity();
    b = Matrix3f::Constant(3);
    res = a+b; // OK: res is resized to size 3x3

    cout << a << endl << endl;
    cout << b << endl << endl;
    cout << res << endl << endl;
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

通过Map方式初始化

/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    std::vector<float> stlarray(10);
    VectorXf::Map(&stlarray[0], stlarray.size()).squaredNorm();

    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 下面的代码没有完全调通
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    const int rows = 3;
    const int cols = 4;
    float array[rows*cols];
    Map<MatrixXf> m(array,rows,cols);
    Matrix3f othermatrix1 = Matrix3f::Identity();//单位矩阵
    MatrixXf othermatrix2(3,4);
    othermatrix2 = MatrixXf::Constant(3,4,5);//3x4的常量矩阵,值都为5
    m = othermatrix1 * othermatrix2;
    //m.eigenvalues();
    std::vector<float> stlarray(10);
    VectorXf::Map(&stlarray[0], stlarray.size()).squaredNorm();
    cout << m << endl;
    return 0;
}
  • 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

通过逗号初始化

/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    Matrix3f m;
    m << 1, 2, 3,
        4, 5, 6,
        7, 8, 9;
    cout << m << endl;
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 使用逗号和子矩阵,初始化矩阵。
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    int rows=5, cols=5;
    MatrixXf m(rows,cols);
    m << (Matrix3f() << 1, 2, 3, 4, 5, 6, 7, 8, 9).finished(),//左上角3x3
        MatrixXf::Zero(3,cols-3), //右上角3x2
        MatrixXf::Zero(rows-3,3), //左下角2x3
        MatrixXf::Identity(rows-3,cols-3); //右下角2x2

    cout << m << endl;
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • .finished()用于当临时矩阵初始化完成时,获取实际的矩阵对象。尽管看起来很复杂,但实际上编译时已经优化。

算术操作

传统的数学运算

  • 矩阵/向量乘法:
col2 = mat1 * col1; //矩阵x列向量
row2 = row1 * mat1;  // 行向量x矩阵
row1 *= mat1;
mat3 = mat1 * mat2; 
mat3 *= mat1;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 矩阵/向量加法/减法:
mat3 = mat1 + mat2; 
mat3 += mat1;
mat3 = mat1 - mat2; 
mat3 -= mat1;
  • 1
  • 2
  • 3
  • 4
  • 标量加法/减法:
mat3 = mat1 * s1; 
mat3 = s1 * mat1; 
mat3 *= s1;
mat3 = mat1 / s1; 
mat3 /= s1;
  • 1
  • 2
  • 3
  • 4
  • 5

逐元素的操作

  • 逐元素的操作,请查阅.cwise()

  • 逐元素乘法

mat3 = mat1.cwise() * mat2;
  • 1
  • 加/减标量
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise() + scalar;
mat3.cwise() += scalar;
mat3.cwise() -= scalar;
  • 1
  • 2
  • 3
  • 4
  • 逐元素除法
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise() / mat2;
  • 1
  • 2
  • 逐元素取倒数
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise().inverse();
  • 1
  • 2
  • 逐元素比较运算
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise() < mat2;
mat3 = mat1.cwise() <= mat2;
mat3 = mat1.cwise() > mat2;
//等
  • 1
  • 2
  • 3
  • 4
  • 5
  • 三角余弦 
    • sin(), cos()等。
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise().sin();
// 等
  • 1
  • 2
  • 3
  • 指数 
    • pow(), square(), cube(), sqrt(), exp(), log()等。
//需要Array模块 #include <Eigen/Array>
mat3 = mat1.cwise().square();
mat3 = mat1.cwise().pow(5);
mat3 = mat1.cwise().log();
//等
  • 1
  • 2
  • 3
  • 4
  • 5
  • 最小值,最大值,绝对值
mat3 = mat1.cwise().min(mat2);
mat3 = mat1.cwise().max(mat2);
mat3 = mat1.cwise().abs();
mat3 = mat1.cwise().abs2();
  • 1
  • 2
  • 3
  • 4
  • 各种乘法运算

    • 矩阵乘法:m1*m2
    • 逐元素乘法:mat1.cwise()*mat2
    • 点积:scalar = vec1.dot(vec2);
    • 外积:mat = vec1 * vec2.transpose();
    • 交叉积:#include <Eigen/Geometry> vec3 = vec1.cross(vec2);
  • 逐元素操作示例:

/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Eigen>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    Matrix3f x, y;
    x << 5,3,1,2,-7,8,9,-4,6;
    y << 5,3,1,2,-7,8,9,4,7;
    cout << x << endl << endl;
    cout << x.cwiseAbs() << endl << endl;//绝对值
    cout << x.cwiseAbs2() << endl << endl; //平方
    cout << x.cwiseEqual(y) << endl << endl; //是否相等
    cout << x.cwiseMax(y) << endl << endl; //逐元素最大值
    cout << x.cwiseMin(y) << endl << endl;
    cout << x.cwiseInverse() << endl << endl; //倒数
    cout << x.cwiseNotEqual(y) << endl << endl; //不相等
    cout << x.cwiseProduct(y) << endl << endl; //逐元素乘法
    cout << x.cwiseQuotient(y) << endl << endl; //除法
    cout << x.cwiseSqrt() << endl << endl; //
    return 0;
}
  • 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

Reductions

  • Eigen提供了一些reduction方法: minCoeff() , maxCoeff() , sum() , trace() , norm() , squaredNorm() , all() , 和 any()。
  • 上述这些方法都可以逐列或逐行的执行。如下所示:
/*
 * 参考链接:http://eigen.tuxfamily.org/dox-2.0/TutorialCore.html#TutorialCoreGettingStarted
*/

#include <iostream>
#include <vector>
#include <Eigen/Core>

using namespace Eigen;  
using namespace std;  

int main(int, char *[])
{
    Matrix3f x;
    x << 5,3,1,2,7,8,9,4,6;
    cout << x.minCoeff() << endl;
    cout << x.colwise().minCoeff() << endl;
    cout << x.rowwise().minCoeff() << endl;

    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • maxCoeff()和minCoeff()函数可以通过设置可选参数,返回最大/小值的位置:maxCoeff(int* i, int* j) , minCoeff(int* i, int* j) 。
  • all() 和 any()在使用逐元素操作时,非常有用。

参考


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

eigen 教程和指南 的相关文章

  • 天地图服务与开发

    天地图服务与开发 天地图在线地图网址 2021年7月2日 国家地理信息公共服务平台天地图2021版正式启用 传统版地址 https map tianditu gov cn 2020 新版地址 https map tianditu gov c
  • ssh telnet linux中显示中文

    vi etc sysconfig i18n 将内容改为 LANG zh CN GB18030 LANGUAGE zh CN GB18030 zh CN GB2312 zh CN SUPPORTED zh CN GB18030 zh CN z
  • office中excel设置下拉框多选

    我参照了这篇文章 https www php cn topic excel 444717 html 这篇文章整体写得不错 但是有些小瑕疵 问题1 在模块1中保存 这里并没有说清楚 具体是 VBA编辑器中 插入 模块 然后复制以下代码 Pub
  • js if else return不管用_前端知识013 学会异步,JS不再烧脑

    01 同步和异步 0101 认识同步异步 0102 前端经常遇到的异步操作 三个经典例子 0103 拿到异步的结果 轮询和回调 0104 回调的几种方式 02 Promise 0201 Promise基本用法 0202 Promise 基本
  • 【打卡-蓝桥杯】Day 7

    题目1 基础练习 芯片测试 解题思路 因为好的芯片多于坏的 所以如果是好芯片 那个被测试为 1 的 总数 gt n 2 代码 n int input arr list map int input split for in range n f

随机推荐

  • python自动化控制设备有限公司_华为 Python网络自动化

    哈喽 大家好 我是艺博东 是一个思科出身 专注于华为的网工 好了 话不多说 我们直接进入正题 光棍二十年 不知道情人节是什么鬼东西 还是好好学技术吧 努力 奋斗吧 为了早日走向人生巅峰 迎娶白富美 拼了 1 安装环境并导入相关模块 首先是安
  • 错误 0xc0202009: 数据流任务 1: SSIS 错误代码 DTS_E_OLEDBERROR。出现 OLE DB 错误。

    原来是一个varchar字段出出现了 和 等特殊字符 这个在insert语句中没有问题 但是使用导入导出会报错 最后要注意的是 导入导出使用的是BulkInsert 方式 每次可能读取一大段 多行记录一起处理 如果这批数据中有错 那么 程序
  • html5注册阿里巴巴作业,面试分享:2018阿里巴巴前端面试总结(题目+答案)

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 使用js实现一个持续的动画效果 最开始的思路是用定时器实现 最后没有想的太完整 面试官给出的答案是用 requestAnimationFrame var e document getElemen
  • Java基础(四)——多态、抽象类、接口、内部类

    一 多态 1 多态性是指同一操作作用于某一类对象 可以有不同的解释 产生不同的执行效果 同一事件发生在不同的对象身上 有不同的效果 2 多态存在的三个必要条件 a 需要存在继承和实现关系 b 同样的方法调用而执行不同操作 运行不同代码 重写
  • JS 中把对象按属性名字母顺序进行排序和倒序

    本文同步发布在 JS 中把对象按属性名字母顺序进行排序和倒序 我们在进行前端开发的时候 有时需要对参数进行签名 签名很多第一步是把对象按属性名字母顺序进行排序 那么在 JS 中如何实现呢 实现方式很多 这边介绍一种通过 ES6 的方式来实现
  • Andy‘s First Dictionary C++ STL set应用

    目录 题目描述 思路分析 代码 题目描述 原文 Andy 8 has a dream he wants to produce his very own dictionary This is not an easy task for him
  • vue实现动态锚点

    div class dialog header item item div 需要点击的目标增加click事件 并且把索引传下去 没有索引也没有关系 想传什么传什么 锚点 getActiveClass index let jump docum
  • 「网页开发|前端开发|Vue」05 Vue实战:从零到一实现一个网站导航栏

    本文主要介绍如何从最开始的草图 通过确定基本结构 修改元素布局 美化外观来实现一个网站导航栏 从而熟悉网页开发的基本流程 同时 我们会把性能 规范性 可维护性方面的代码优化也考虑其中 文章目录 本系列前文传送门 一 场景说明 设计目标 二
  • 几种常用激活函数的简介

    1 sigmod函数 函数公式和图表如下图 在sigmod函数中我们可以看到 其输出是在 0 1 这个开区间内 这点很有意思 可以联想到概率 但是严格意义上讲 不要当成概率 sigmod函数曾经是比较流行的 它可以想象成一个神经元的放电率
  • Python正则表达式学习(3)——re.compile()

    re compile pattern flags 0 将正则表达式 pattern 编译为正则表达式对象 可用于使用其 match 和search 方法进行匹配 顺序 prog re compile pattern result prog
  • Pinctrl子系统之一了解基础概念

    1 Linux Pinctrl子系统简介 在许多soc内部都包含有pin控制器 通过pin控制器的寄存器 我们可以配置一个或者一组引脚的功能和特性 在软件方面 Linux内核提供了pinctrl子系统 目的是为了统一各soc厂商的pin脚管
  • TreeView —WPF—MVVM—HierarchicalDataTemplate

    摘要 采用HierarchicalDataTemplate数据模板和treeview在MVVM模式下实现行政区划树 支持勾选 勾选父节点 子节点回全部自动勾选 子节点部分勾选时 父节点半勾选 子节点全部勾选时 父节点勾选 反之亦然 Hier
  • 吴恩达9.3 反向传播的直观理解

    为了更好地理解反向传播算法 我们再来仔细研究一下前向传播的原理 前向传播算法 反向传播算法做的是
  • Qt基础——UI文件.h文件说明

    首先 需要使用Qt Designer设计你的UI界面 Qt号称是跨平台应用程序和UI开发框架 所以其自带的UI设计器 即Qt Designer 功能也非常强大 除了通常用的如Button List等组件外面 使用Qt Designer做UI
  • mac出现wifi没有ip地址无法接入互联网

    问题 情况 wifi已经输入密码正确 但是中间出现灰色的wifi图标 还有一个叹号 说是没有IP地址 解决方法 1 试过重启 2 试过删掉该网络再重新输入密码 3 试过删掉WiFi一栏 来自百度 最佳答案 1 首先打开偏好设置 点击网络选项
  • 用Python赚钱的方法有哪些?

    很多人想知道用Python赚钱的方法有哪些 Python很容易使用 应用性较强 可以通过使用Python开发小程序 抓取数据 游戏开发 兼职编程老师 发展副业的方式来赚钱 文末有福利 用Python赚钱的方法 1 某宝搜python程序 可
  • java多线程设计模式

    1 I O处理比较花费时间 故把执行I O处理和非IO处理的线程分开 CPU执行速度很快 而内存的写入 读取很慢 所以有关CPU和内存交互会降低指令的速度 2 start方法运行有2个步骤 启动新的线程 运行new对象的run方法 3 所有
  • AD19 PCB设计导入元件库、导出pdf、定义板子形状、生成元件库、铺铜基本操作总结

    导入元件库 1 点击右侧components 2 右键 然后选择 Add or Remove Libraries 3 点击从文件安装 4 选择库文件 导出PDF 导出原理图或者pcb等信息pdf操作 文件 gt 智能pdf 定义板子形状 使
  • 慕课第四周第7题 出租车计价

    出租车计价 4分 题目内容 已知某城市普通出租车收费标准为 起步里程为3公里 起步费为8元 10公里以内超过起步里程的部分 每公里加收2元 超过10公里以上的部分加收50 的回空补贴费 即每公里3元 出租车营运过程中 因堵车和乘客要求临时停
  • eigen 教程和指南

    转自 http eigen tuxfamily org dox 2 0 TutorialCore html https blog csdn net xuezhisdc article details 54619853 固定大小的矩阵和向量