sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
870c3d3d0e4ebcdd73d7ef7fec41676b4618f898d5a600d9df2a15e5467ccb45 | C++ | 187 | 3 | MatrixXd ones = MatrixXd::Ones(3,3);
VectorXd eivals = ones.selfadjointView<Lower>().eigenvalues();
cout << "The eigenvalues of the 3x3 matrix of ones are:" << endl << eivals << endl;
|
2b4431a6a75eeab3c7fc3eb799864193e2dcd79bd786d3270ac2e3f6a211e99d | C++ | 188 | 5 | int data[] = {1,2,3,4,5,6,7,8,9};
Map<RowVectorXi> v(data,4);
cout << "The mapped vector v is: " << v << "\n";
new (&v) Map<RowVectorXi>(data+4,5);
cout << "Now v is: " << v << "\n";
|
f56c527c88dc5eb99b54140f37b64a575d78cc64f211f7c2daeda971087c774a | C++ | 188 | 11 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// call meta()
std::cout << std::setw(4) << json::meta() << '\n';
}
|
cd0d806c5d2ffaef002de7432e70d50042fc7e2715a361c3336e7e7dc5c28def | C++ | 190 | 4 | MatrixXi m = MatrixXi::Random(2,3);
cout << "Here is the matrix m:" << endl << m << endl;
cout << "m.colwise().replicate<3>() = ..." << endl;
cout << m.colwise().replicate<3>() << endl;
|
c1b8e58ece443d3ae291424d338cfa1f8e4b4c2c1357ce2fe9f8ac78be27bb0e | C++ | 192 | 4 | Matrix3i m = Matrix3i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here are the coefficients on the main diagonal of m:" << endl
<< m.diagonal() << endl;
|
99d03078fbcd91ccc1468ee5a9be00df88dac606f6553da19c9f9e64c95df828 | C++ | 193 | 5 | Matrix2i a; a << 1, 2, 3, 4;
cout << "Here is the matrix a:\n" << a << endl;
a = a.transpose(); // !!! do NOT do this !!!
cout << "and the result of the aliasing effect:\n" << a << endl;
|
f8306196a5b88d64da117d7eb1920479e40310e3b291ce8519d7c8962ad6227e | C++ | 194 | 22 | struct vec4
{
static int length();
};
int vec4::length()
{
return 4;
}
int main()
{
int Failed = 0;
vec4 V;
int LengthA = V.length();
int LengthB = vec4::length();
return Failed;
}
|
c780b394e6702d2489c1e7c634623649d7acce35bb5f7ccde89d3f4ec6b036e1 | C++ | 195 | 5 | #if EIGEN_HAS_STATIC_ARRAY_TEMPLATE
MatrixXi A = MatrixXi::Random(4,6);
cout << "Initial matrix A:\n" << A << "\n\n";
cout << "A(all,{4,2,5,5,3}):\n" << A(all,{4,2,5,5,3}) << "\n\n";
#endif
|
96e08e5df8feefe6b40014a7433c1ef62d7a719dc64bd0ca18e88b1c56f44a50 | C++ | 196 | 4 | MatrixXf A = MatrixXf::Random(3, 2);
VectorXf b = VectorXf::Random(3);
cout << "The solution using normal equations is:\n"
<< (A.transpose() * A).ldlt().solve(A.transpose() * b) << endl;
|
ca1f1b35b21ab1abe2a0113b3bbddab6deec59dd5c3baaca8ea7ebe73c4b6261 | C++ | 197 | 14 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define ROWS Dynamic
#else
#define ROWS 3
#endif
using namespace Eigen;
int main()
{
Matrix<int, ROWS, 1> {1, 2, 3};
}
|
ebb6d498b5e64debc81a3518ea2e09cb0c10c44318b7641ca21981989183fc94 | C++ | 197 | 4 | MatrixXd ones = MatrixXd::Ones(3,3);
SelfAdjointEigenSolver<MatrixXd> es(ones);
cout << "The first eigenvector of the 3x3 matrix of ones is:"
<< endl << es.eigenvectors().col(1) << endl;
|
566d72a29931f5ddfa33451d318562c3f36461a89c0d2d5d896ac99805eba03c | C++ | 198 | 9 | #include <Eigen/Core>
#include <unsupported/Eigen/SpecialFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Array4d v(-0.5,2,0,-7);
std::cout << v.erf() << std::endl;
}
|
6c1819488f77ee808835c4ca5cae17cb8fcd0dd8502daea9483d2951cd5eee1f | C++ | 198 | 5 | // stdafx.cpp : source file that includes just the standard includes
// gw_core.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
|
859c9258776cb10fa88140a2a6f2855d0d061866d85f2add61eb616cb4a4a1e7 | C++ | 198 | 5 | MatrixXf a(2,2);
std::cout << "a is of size " << a.rows() << "x" << a.cols() << std::endl;
MatrixXf b(3,3);
a = b;
std::cout << "a is now of size " << a.rows() << "x" << a.cols() << std::endl;
|
a60bc2e8c37d18c968f718300a51f11b91de35314b754a739fd0bb524b84a5a4 | C++ | 198 | 4 | MatrixXcf ones = MatrixXcf::Ones(3,3);
ComplexEigenSolver<MatrixXcf> ces(ones);
cout << "The first eigenvector of the 3x3 matrix of ones is:"
<< endl << ces.eigenvectors().col(1) << endl;
|
4e8ddef6454fd6fbd8e581c29df689a63934d936e8c33c495ec0fcc1b0ac5b7b | C++ | 199 | 9 | #include <Eigen/Core>
#include <unsupported/Eigen/SpecialFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Array4d v(-0.5,2,0,-7);
std::cout << v.erfc() << std::endl;
}
|
5dc1c5d9bbff2f1d49308018866b2fb5b0c8588b6dd93ce203a2eae7521b0b11 | C++ | 201 | 9 | #include <Eigen/Core>
#include <unsupported/Eigen/SpecialFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Array4d v(0.5,10,0,-1);
std::cout << v.lgamma() << std::endl;
}
|
05c48226a3fc81245e8e1860d338eab0019c31c591e3c482d18c4dc21ad79db1 | C++ | 204 | 5 | int array[12];
for(int i = 0; i < 12; ++i) array[i] = i;
cout << Map<VectorXi, 0, InnerStride<2> >
(array, 6) // the inner stride has already been passed as template parameter
<< endl;
|
5f3bae03b8b57b44310f2ad2f51593f17fd8caaf2a29a77d73404c768a8598a4 | C++ | 205 | 12 | #include "gemm_common.h"
EIGEN_DONT_INLINE
void gemm(const Mat &A, const Mat &B, Mat &C)
{
C.noalias() += A * B;
}
int main(int argc, char **argv)
{
return main_gemm(argc, argv, gemm);
}
|
da106ccababeac6313ce7b5552577fa54dc3b33a190f13c53d6a0376c84e98d0 | C++ | 205 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void gemv(const Mat &A, const Vec &B, Vec &C)
{
C.noalias() += A * B;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, gemv);
}
|
1415bf57d681329bf489f97673d7bdc2c65d0f1a924c91693b3214758757c9eb | C++ | 206 | 15 | #include "mpicomm.h"
namespace nastja {
static MPI_Comm active_comm = MPI_COMM_WORLD;
void set_mpi_comm(MPI_Comm comm) {
active_comm = comm;
}
MPI_Comm get_mpi_comm() {
return active_comm;
}
}
|
3c2554f666e91d9656f3f8e93a9e613dbe422c7ceceba74c5a79f97f75bb463e | C++ | 206 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl;
}
|
1a6da71c190179c2860fdb024377eb679e8aa49cb4fabb3704a177afa1189534 | C++ | 207 | 4 | Array4i v = Array4i::Random().abs();
cout << "Here is the initial vector v:\n" << v.transpose() << "\n";
std::sort(v.begin(), v.end());
cout << "Here is the sorted vector v:\n" << v.transpose() << "\n";
|
314ac5faa9e8eacef7bcad1ea725ccfe1176ae3dabf99a2107307cd95be1ba78 | C++ | 211 | 11 | #include <iostream>
#include <fstream>
#include <numeric>
#include <vector>
#include <gtest/gtest.h>
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
231005fd3ad140b78bfe4215d706593e02862b3555433789fbe634b3c8316aa3 | C++ | 212 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::string, json::string_t>::value << std::endl;
}
|
62604bace76779580275fbf709aa938b22795c97b090979c119f0d2f2f1cb55b | C++ | 213 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<double, json::number_float_t>::value << std::endl;
}
|
d84802f4997138d8ac433096f0524719d885e271eee8647e9da676d4f3d86bd4 | C++ | 214 | 7 | Matrix3f A = Matrix3f::Random(3,3), B;
B << 0,1,0,
0,0,1,
1,0,0;
cout << "At start, A = " << endl << A << endl;
A.applyOnTheLeft(B);
cout << "After applyOnTheLeft, A = " << endl << A << endl;
|
0e82c1756e5774feef1322bf0b66a40b81ea9ad9fdfe2e342358132db2ee2cec | C++ | 215 | 5 | Matrix3f m;
m = AngleAxisf(0.25*M_PI, Vector3f::UnitX())
* AngleAxisf(0.5*M_PI, Vector3f::UnitY())
* AngleAxisf(0.33*M_PI, Vector3f::UnitZ());
cout << m << endl << "is unitary: " << m.isUnitary() << endl;
|
1210a1d53933998dba5ed08ab7c54d6601cb5d06ce31496ab1401f2e89ca7afd | C++ | 217 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void gemv(const Mat &A, Vec &B, const Vec &C)
{
B.noalias() += A.transpose() * C;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, gemv);
}
|
ae3df98d1d65b96ff81db9ad34146efe169e7b3cf471959f592b34422e79edfa | C++ | 217 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
}
|
2249e283bf4cc415a05f7c154abce7fef4fee1ac35cc3655964854a62e117937 | C++ | 220 | 5 | Matrix3d m = Matrix3d::Zero();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isZero() returns: " << m.isZero() << endl;
cout << "m.isZero(1e-3) returns: " << m.isZero(1e-3) << endl;
|
487a4b696d2c5699e090d4d2141fd43f54e3c01b77e938948b0c94f14a5d258f | C++ | 220 | 14 | #include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}
|
a461467d4eb22afcd259f4f763b8c30d14236d48fd6cd010e28375d324d99c3d | C++ | 220 | 4 | MatrixXcf ones = MatrixXcf::Ones(3,3);
ComplexEigenSolver<MatrixXcf> ces(ones, /* computeEigenvectors = */ false);
cout << "The eigenvalues of the 3x3 matrix of ones are:"
<< endl << ces.eigenvalues() << endl;
|
0666d91dde7618a10fb02c98f5bd53b7e01c0737856be580c89301e6b54b5cdd | C++ | 221 | 5 | Matrix3d m = Matrix3d::Ones();
m(0,2) += 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isOnes() returns: " << m.isOnes() << endl;
cout << "m.isOnes(1e-3) returns: " << m.isOnes(1e-3) << endl;
|
49de27a8fccd24f3d9e162c015dbd83d49ff9cdfd3c9e5bd7481ac83afa078b0 | C++ | 221 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::int64_t, json::number_integer_t>::value << std::endl;
}
|
45629f7e449bfb345a4de9d34bf5d1d1d36ed1dea872fabe4e1b0c1471197b71 | C++ | 222 | 11 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Source code for a simple DSO.
int DSOTestExtra(int a) {
if (a < 452345)
return 0;
return 1;
}
|
b252fda22e6fc7ec3f8bef505ad7b1f3d9814874886b74ec3ed3d879a237820b | C++ | 222 | 7 | int rows=5, cols=5;
MatrixXf m(rows,cols);
m << (Matrix3f() << 1, 2, 3, 4, 5, 6, 7, 8, 9).finished(),
MatrixXf::Zero(3,cols-3),
MatrixXf::Zero(rows-3,3),
MatrixXf::Identity(rows-3,cols-3);
cout << m;
|
798137e29a44033a7b17d1ee84713c6cd3cdab46cfdcbb361b36c75274ea8b67 | C++ | 223 | 5 | ArrayXXi A = ArrayXXi::Random(4,4).abs();
cout << "Here is the initial matrix A:\n" << A << "\n";
for(auto row : A.rowwise())
std::sort(row.begin(), row.end());
cout << "Here is the sorted matrix A:\n" << A << "\n";
|
ac7e58e12cbfdd0db38f441b1d6c6cf76fbc897b68d00bd01ec3a3688d300126 | C++ | 223 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::uint64_t, json::number_unsigned_t>::value << std::endl;
}
|
32e7d493f3ad5a4fa96136e665255a6c52f2566007e298de8d4216b47f153cb6 | C++ | 224 | 14 | #include <iostream>
#include <nlohmann/json.hpp>
using ordered_json = nlohmann::ordered_json;
int main()
{
ordered_json j;
j["one"] = 1;
j["two"] = 2;
j["three"] = 3;
std::cout << j.dump(2) << '\n';
}
|
c8620da1c9e1742bf0c2f00b0b7792815bd326e12b08fdc16ae984d9facf5f05 | C++ | 225 | 4 | MatrixXcf A = MatrixXcf::Random(4,4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexSchur<MatrixXcf> schurOfA(A);
cout << "The unitary matrix U is:" << endl << schurOfA.matrixU() << endl;
|
f85abb5b5482572b3bb5f73be3cb765b07268c54f421a639bbc8937584dc5d45 | C++ | 225 | 14 | #include "../Eigen/Core"
using namespace Eigen;
int main()
{
VectorXf a(10), b(10);
VectorXf const &ac(a);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b.swap(ac);
#else
b.swap(ac.const_cast_derived());
#endif
}
|
7c76b4304d2401c2fe8e2add8e8ef53042fc131b167d44a0f00e425d01bfc554 | C++ | 226 | 13 | #include "../Eigen/Core"
using namespace Eigen;
int main(int argc,char **)
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b = argc>1 ? 2*a : -a;
#else
b = argc>1 ? 2*a : VectorXf(-a);
#endif
}
|
b19f5abb757746e53af61c12ae78f4afc7eac42df6bab90987880a1c9879d930 | C++ | 228 | 15 | #include "../Eigen/Core"
using namespace Eigen;
void call_ref(Ref<VectorXf> a) { }
int main()
{
MatrixXf A(10,10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(A.row(3));
#else
call_ref(A.col(3));
#endif
}
|
13cf0b00527ef7f54ea9e540b33698767475ebf7c7b1e5a6179f9a6b9dbd7422 | C++ | 229 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void trmv(const Mat &A, const Vec &B, Vec &C)
{
C.noalias() += A.triangularView<Upper>() * B;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, trmv);
}
|
4c7fda77caabd263d9fc82a002037a661909540a72582f7cd79c06df2b268ea4 | C++ | 229 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void trmv(const Mat &A, const Vec &B, Vec &C)
{
C.noalias() += A.triangularView<Lower>() * B;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, trmv);
}
|
16ba214b544b084e0aa890b50caa71673110c033088f7ee53f603d2ed7549a15 | C++ | 231 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.tail(2):" << endl << v.tail(2) << endl;
v.tail(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
99bf49fae4e8c991cbca92de43f6c0f7110e73bdbefae29a6f79618ed10dcc59 | C++ | 231 | 14 | #include "../Eigen/Core"
using namespace Eigen;
int main()
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
const DenseBase<VectorXf> &ac(a);
#else
DenseBase<VectorXf> &ac(a);
#endif
b.swap(ac);
}
|
9b2a4be2322229ac34343481219095e744948c3a9bde8aece263672da7482d50 | C++ | 231 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.head(2):" << endl << v.head(2) << endl;
v.head(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
dd15db9c4e29e87e532f4f12f7d4ab517afa567cfe3e5bff94ca8a67232c21f8 | C++ | 231 | 10 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::map<json::string_t, json>, json::object_t>::value << std::endl;
}
|
b9d82dd1cd31533e42bbd6f5fab1cfd5868b3b812bbb9f3856429f8b360bf2e6 | C++ | 235 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.tail(2):" << endl << v.tail<2>() << endl;
v.tail<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
fd756f89512fe874e7e3cb628ecef2cf6f3469b761040c271cb460d70449029d | C++ | 235 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.head(2):" << endl << v.head<2>() << endl;
v.head<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
0ecc29e58053209e62e5a2b75ba42da9a2e45bc4a59f65123d50ec446e4ad102 | C++ | 236 | 12 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Source code for a simple DSO.
int DSO1(int a) {
if (a < 123456)
return 0;
return 1;
}
void Uncovered1() { }
|
5acb1b68f3a1a6c14c02b6599fad322867e71bc6a8afb7f27f2a321792143143 | C++ | 236 | 4 | Array<double,1,3> x(8,25,3),
e(1./3.,0.5,2.);
cout << "[" << x << "]^[" << e << "] = " << x.pow(e) << endl; // using ArrayBase::pow
cout << "[" << x << "]^[" << e << "] = " << pow(x,e) << endl; // using Eigen::pow
|
6f3318ccb78e8c83fb6bd7ff4f9991bb89d6cda2c9edaff5290542143c6d1513 | C++ | 236 | 12 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Source code for a simple DSO.
int DSO2(int a) {
if (a < 3598235)
return 0;
return 1;
}
void Uncovered2() {}
|
71cb87df8bdb7996543529f34a34b6f3ccd3ed8006358088d7140249ef61cb99 | C++ | 236 | 5 | Matrix3d m = Matrix3d::Identity();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isUnitary() returns: " << m.isUnitary() << endl;
cout << "m.isUnitary(1e-3) returns: " << m.isUnitary(1e-3) << endl;
|
88b6bdb4e3320a644b48d96fdb6858d96bb385cc3e04d6c7b7c8bde8599929f0 | C++ | 238 | 13 | #include "../Eigen/Core"
using namespace Eigen;
int main(int argc,char **)
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b = argc>1 ? 2*a : a+a;
#else
b = argc>1 ? VectorXf(2*a) : VectorXf(a+a);
#endif
}
|
b46ea4cf874d237a17fc62a40961aa8fdcc0d5f5b823d5cb057ed0ae14139bca | C++ | 238 | 16 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define ROWS Dynamic
#define COLS Dynamic
#else
#define ROWS 3
#define COLS 1
#endif
using namespace Eigen;
int main()
{
Matrix<int, ROWS, COLS> {1, 2, 3};
}
|
ecf66c2100741b843f1e8aa7b1aa9c2f2517540768cca224e3643a2a65fb014d | C++ | 238 | 4 | Vector3d v(-1,2,-3);
cout << "the absolute values:" << endl << v.array().abs() << endl;
cout << "the absolute values plus one:" << endl << v.array().abs()+1 << endl;
cout << "sum of the squares: " << v.array().square().sum() << endl;
|
0a557b1ff1ebc41e46a8159d4b9eae2329ed9883f8f286bfae6ed50b595581d6 | C++ | 239 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER float *ptr){
Map<Matrix3f> m(ptr);
}
int main() {}
|
e31e15118a56e5aa0876b7cc2d54e88556091fbdd9095bf578344ffacf93efd0 | C++ | 239 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.topRows(2):" << endl;
cout << a.topRows(2) << endl;
a.topRows(2).setZero();
cout << "Now the array a is:" << endl << a << endl;
|
3ecd0fb38c9903bbcae1ae25a9408a7602256d7cffb8ec6a9597bc17465a883d | C++ | 240 | 10 | MatrixXf matA(2,2), matB(2,2);
matA << 2, 0, 0, 2;
// Simple but not quite as efficient
matB = matA * matA;
cout << matB << endl << endl;
// More complicated but also more efficient
matB.noalias() = matA * matA;
cout << matB;
|
8980abe292fe65d2593186212f51ee7fa4582c059e7610e5ccba2c0b0bba4043 | C++ | 240 | 5 | Matrix3d m = Matrix3d::Identity();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isIdentity() returns: " << m.isIdentity() << endl;
cout << "m.isIdentity(1e-3) returns: " << m.isIdentity(1e-3) << endl;
|
64082b650a186efcd11e9832e6db79db9e5f28d7231474469e484c064731cd49 | C++ | 241 | 12 | #include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Matrix4d m;
m.resize(4,4); // no operation
std::cout << "The matrix m is of size "
<< m.rows() << "x" << m.cols() << std::endl;
}
|
b8c4a0ff2a6d4f6867d30aa7b4ecc82aecf9ba9fbb29a644282f7a1931516807 | C++ | 241 | 6 | VectorXd v(10);
v.resize(3);
RowVector3d w;
w.resize(3); // this is legal, but has no effect
cout << "v: " << v.rows() << " rows, " << v.cols() << " cols" << endl;
cout << "w: " << w.rows() << " rows, " << w.cols() << " cols" << endl;
|
bda143fa033a7f3a05bf1f30ab80dca3d23f502abeb97eaf202292d7e6f4f9c7 | C++ | 241 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void trmv(const Mat &A, Vec &B, const Vec &C)
{
B.noalias() += A.transpose().triangularView<Upper>() * C;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, trmv);
}
|
caf7e742f7d3ca2997091eee495fc7d47fbe323c5ee144444900e1e87b620e34 | C++ | 241 | 12 | #include "gemv_common.h"
EIGEN_DONT_INLINE
void trmv(const Mat &A, Vec &B, const Vec &C)
{
B.noalias() += A.transpose().triangularView<Lower>() * C;
}
int main(int argc, char **argv)
{
return main_gemv(argc, argv, trmv);
}
|
b1e495be128b912e172cbb169a4fdfa6812951dffee1d79608783f76a487de30 | C++ | 242 | 6 | Vector2f v = Vector2f::Random();
JacobiRotation<float> G;
G.makeGivens(v.x(), v.y());
cout << "Here is the vector v:" << endl << v << endl;
v.applyOnTheLeft(0, 1, G.adjoint());
cout << "Here is the vector J' * v:" << endl << v << endl;
|
b901b2342681ae5d3279702f0a30581c8d47752355e086821e2e4e5c1072d33a | C++ | 242 | 15 | #include "../Eigen/Core"
using namespace Eigen;
void call_ref(Ref<MatrixXf,0,OuterStride<> > a) {}
int main()
{
MatrixXf A(10,10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(A.transpose());
#else
call_ref(A);
#endif
}
|
e95515c3cf5c65f88c8d05a3a42256e487f28078db0b82d706fc2cea974001a8 | C++ | 242 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.leftCols(2):" << endl;
cout << a.leftCols(2) << endl;
a.leftCols(2).setZero();
cout << "Now the array a is:" << endl << a << endl;
|
4b3d323872809dd4f1f536a1417b5d70863e46d5f8478db94af6c6b36e80f686 | C++ | 243 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Diagonal<Matrix3d> d(m);
}
int main() {}
|
372ca51a9ed5474eed29f029f1855fe99a3ef2d70fbe98c0a64f4a220ffee3b0 | C++ | 244 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Transpose<Matrix3d> t(m);
}
int main() {}
|
613c9037b7339e0bcc292660ed8b1c4c6eb8f19e433d2209b9b8bb4f9f5ca3a4 | C++ | 245 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.topRows<2>():" << endl;
cout << a.topRows<2>() << endl;
a.topRows<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;
|
71386ddb0fcd2621ae669a20c02a124c2a77b93927279419d165695aef190806 | C++ | 245 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.rightCols(2):" << endl;
cout << a.rightCols(2) << endl;
a.rightCols(2).setZero();
cout << "Now the array a is:" << endl << a << endl;
|
a5eeb9634cb8f2549a721563105772273fcc765ec0f1f6e6d2b57d31d88315b5 | C++ | 246 | 13 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON poiner
json::json_pointer ptr("/foo/bar/baz");
// write string representation to stream
std::cout << ptr << std::endl;
}
|
f1e560b849cf8a6de51d8853068a2494e4c69f01115e59eed0ef4aeb2846602f | C++ | 246 | 15 | #include "../Eigen/Core"
using namespace Eigen;
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
void call_ref(Ref<VectorXf> a) { }
#else
void call_ref(const Ref<const VectorXf> &a) { }
#endif
int main()
{
VectorXf a(10);
call_ref(a+a);
}
|
7ff9e76bf898b0e2631b97f4b43385adca40be7c99bf23163cfd2754ba5cd154 | C++ | 247 | 6 | Matrix3d m = 10000 * Matrix3d::Identity();
m(0,2) = 1;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isDiagonal() returns: " << m.isDiagonal() << endl;
cout << "m.isDiagonal(1e-3) returns: " << m.isDiagonal(1e-3) << endl;
|
7ab9ca552f78b6a3f4524a0a1bd10df239d2f2eae82d586b207a527cc4735c0e | C++ | 248 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Block<Matrix3d> b(m,0,0,3,3);
}
int main() {}
|
affe7da173a2119483b3e08ae96a9de6fd772ae417b0ab358f1e0ab20af9517a | C++ | 248 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Block<Matrix3d,3,3> b(m,0,0);
}
int main() {}
|
b95ac967956cfd258dbc4edf639bc6997376a8eaf4872d8fa2349df297e521b1 | C++ | 248 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.bottomRows(2):" << endl;
cout << a.bottomRows(2) << endl;
a.bottomRows(2).setZero();
cout << "Now the array a is:" << endl << a << endl;
|
ce790e21d90c6544dbcd812b788ed17105137f0b25e76f0e84c418733f9d4981 | C++ | 248 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.leftCols<2>():" << endl;
cout << a.leftCols<2>() << endl;
a.leftCols<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;
|
10d814b1676a3c231cdfe364d1038ae35b7070803fc35b366406bfa2a80a74ac | C++ | 249 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment<2>(1):" << endl << v.segment<2>(1) << endl;
v.segment<2>(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
8736303f5d82e72c4c9832cd8d915ef16c172afd73b4573b7cd137612783c3e5 | C++ | 249 | 5 | RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment(1, 2):" << endl << v.segment(1, 2) << endl;
v.segment(1, 2).setZero();
cout << "Now the vector v is:" << endl << v << endl;
|
c89bc71fdb6f991677a4d762c165ea92cdfc80c891e21d69220f1535e204b9f6 | C++ | 249 | 5 | Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block<2,2>(1,1):" << endl << m.block<2,2>(1,1) << endl;
m.block<2,2>(1,1).setZero();
cout << "Now the matrix m is:" << endl << m << endl;
|
d64d980767c719473791ccba77c6913f605b2e71580a9e78614c339f2bde282a | C++ | 250 | 15 | #include "../Eigen/Sparse"
using namespace Eigen;
void call_ref(Ref<SparseMatrix<float> > a) {}
int main()
{
SparseMatrix<float> A(10,10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(A.transpose());
#else
call_ref(A);
#endif
}
|
0a4989939a4b0b846778f85cd03ad53fc7b29e3118279d47e63a965d235d65a0 | C++ | 251 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.rightCols<2>():" << endl;
cout << a.rightCols<2>() << endl;
a.rightCols<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;
|
286a275ee57019a35a8f2e3b16e62f7da435adc7596e9d698ea796f66a764e4e | C++ | 253 | 15 | #include "../Eigen/Sparse"
using namespace Eigen;
void call_ref(Ref<SparseMatrix<float> > a) { }
int main()
{
SparseMatrix<float> A(10,10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(A.row(3));
#else
call_ref(A.col(3));
#endif
}
|
3c2d6e2b905e52971baeb7a8eb05efe674c191c7bad17e72264b7b82614b6e1d | C++ | 253 | 16 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXXf a(2,2);
ArrayXXf b(2,2);
a << 1,2,
3,4;
b << 5,6,
7,8;
cout << "a * b = " << endl << a * b << endl;
}
|
886028d644f9df08fcb147fe2b3086e873172457aefe1c0a7edd9b0c9fd38859 | C++ | 253 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
TriangularView<Matrix3d,Upper> t(m);
}
int main() {}
|
0a5ec9ddce3051926566e57617de3794db7f7f08590cfd03c7920b8c4226bbc3 | C++ | 254 | 6 | Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.bottomRows<2>():" << endl;
cout << a.bottomRows<2>() << endl;
a.bottomRows<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;
|
348673e0e3011fcd8d008fffd364e699dbb48ef15766eb9de58438719383b35a | C++ | 254 | 13 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
json j = R"( {"hello": "world", "answer": 42} )"_json;
std::cout << std::setw(2) << j << '\n';
}
|
957809a1e88e470a37c1247e747a924591029fc32db6eb046256f208683d5538 | C++ | 254 | 16 | #include "../Eigen/Core"
using namespace Eigen;
void call_ref(Ref<VectorXf> a) { }
int main()
{
VectorXf a(10);
DenseBase<VectorXf> &ac(a);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(ac);
#else
call_ref(ac.derived());
#endif
}
|
b8bfb9e0727aeea9d968fc08d4134034c12e9e8d9316c40acb3ccff7c1c310f7 | C++ | 254 | 5 | MatrixXi m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.reshaped(2, 8):" << endl << m.reshaped(2, 8) << endl;
m.resize(2,8);
cout << "Here is the matrix m after m.resize(2,8):" << endl << m << endl;
|
eece9a54869f22508d0401c996a5c49770789e997627c99bd53aea5b0315966c | C++ | 254 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Diagonal<Matrix3d> b(m.diagonal());
}
int main() {}
|
7f2d412bbdfe6aa4dd819ace8bfc4f2616b0dacbe9076cf37b74b2d012d4c0a0 | C++ | 255 | 14 | #include <dispatch/dispatch.h>
#include <stdio.h>
int main() {
dispatch_queue_t queue = dispatch_queue_create(NULL, NULL);
dispatch_sync(queue, ^{
printf("Hello, world from a dispatch queue!\n");
});
dispatch_release(queue);
return 0;
} |
9890e317afa4ec3707fd695e2033e63015956d324f291b6ec7777f4831674304 | C++ | 255 | 5 | Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block(1, 1, 2, 2):" << endl << m.block(1, 1, 2, 2) << endl;
m.block(1, 1, 2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;
|
da4a30820c12121e93ae2ddf3a861d4ea5ef6fdd190d0b5548edfc8578ce0067 | C++ | 255 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Block<Matrix3d> b(m.block(0,0,3,3));
}
int main() {}
|
5f1aa53d882659353bb9b7d1e202e2e8c660febb10ff1fdf245401dbeab2a9fa | C++ | 256 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(float *ptr){
Map<CV_QUALIFIER Vector3f>(ptr).coeffRef(0) = 1.0f;
}
int main() {}
|
66f90b2784a1e39feb71b0992b491cab9dd1aff26f0d67be12046ac036b39750 | C++ | 256 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
Transpose<Matrix3d> b(m.transpose());
}
int main() {}
|
c29510dcc49c8186a07d787ce6dfec8e97a03e1e1a9260101157004f2b9613a2 | C++ | 256 | 15 | #include "../Eigen/Core"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define CV_QUALIFIER const
#else
#define CV_QUALIFIER
#endif
using namespace Eigen;
void foo(CV_QUALIFIER Matrix3d &m){
SelfAdjointView<Matrix3d,Upper> t(m);
}
int main() {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.