sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
b78f51756a85f1ad4a28a6029895fc04180d05f629198fb3948af9fc1970c70f | C++ | 420 | 15 | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
MatrixXf A = MatrixXf::Random(3, 2);
cout << "Here is the matrix A:\n" << A << endl;
VectorXf b = VectorXf::Random(3);
cout << "Here is the right hand side b:\n" << b << endl;
cout << "The le... |
c0676386c6c13aaec1293f63ce66127eb6744eb962ab5e909b14fb9d5aa3e55b | C++ | 420 | 18 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array by creating copies of a JSON value
json value = "Hello";
json array_0 = json(0, value);
json array_1 = json(1, value);
json array_5 = json(5, value);
// serialize the JSON arrays
... |
55028d2b4a008c434e10c33146741ce626a97ffb593d795f2d833f636e12228b | C++ | 421 | 19 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON pointer
json::json_pointer ptr("/foo");
// append a JSON Pointer
std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n";
// append a string
std::cout << "\"" << ptr / "fob... |
a3ad0cb67ac1e1c241ba10a8e31920ab1be2d76dbd93fe012c92408c5f1a6ca4 | C++ | 421 | 15 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("/foo");
json::json_pointer ptr2("/foo/0");
// call empty()
std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n"
... |
dea9b6c034b8ee16b83063917554f2919e1c1205a446a4c5f9cb733ad320c06b | C++ | 421 | 14 | int n = 10000;
VectorXd x(n), b(n);
SparseMatrix<double> A(n,n);
/* ... fill A and b ... */
BiCGSTAB<SparseMatrix<double> > solver(A);
// start from a random solution
x = VectorXd::Random(n);
solver.setMaxIterations(1);
int i = 0;
do {
x = solver.solveWithGuess(b,x);
std::cout <<... |
cacf2b3ec0bdf202178a8bd479571109d3c1953382300e3231fd5e3a76174729 | C++ | 422 | 8 | Matrix2i m = Matrix2i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the transpose of m:" << endl << m.transpose() << endl;
cout << "Here is the coefficient (1,0) in the transpose of m:" << endl
<< m.transpose()(1,0) << endl;
cout << "Let us overwrite this coefficient with t... |
373f2232d29f6591f7776d51b879b39359ee944863d6a7112ac149f6d60e9501 | C++ | 423 | 13 | Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix3d inverse;
bool invertible;
double determinant;
m.computeInverseAndDetWithCheck(inverse,determinant,invertible);
cout << "Its determinant is " << determinant << endl;
if(invertible) {
cout << "It is invertible, and i... |
473c3a6e79a7712470d4f4ccdfbbe756f33f6464f8ec5577af241dae21a0e283 | C++ | 423 | 15 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text given an input with other values
std::vector<std::uint8_t> input = {'[', '1', ',', '2', ',', '3', ']', 'o', 't', 'h', 'e', 'r'};
// parse and serialize JSON
json j_complete = j... |
fc48ea9949b7b210e5baaabf50c833c6539878c67279ebd71bc04569f4ddc727 | C++ | 423 | 23 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXXf a(3,3);
ArrayXXf b(3,3);
a << 1,2,3,
4,5,6,
7,8,9;
b << 1,2,3,
1,2,3,
1,2,3;
// Adding two arrays
cout << "a + b = " << endl << a + b << endl <... |
b13d7066839653d78df4710c17b56a149ebf2dcf241ed25625f5421f49f077e7 | C++ | 424 | 11 | Matrix<float,2,3> m = Matrix<float,2,3>::Random();
Matrix2f y = Matrix2f::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the matrix y:" << endl << y << endl;
Matrix<float,3,2> x = m.fullPivLu().solve(y);
if((m*x).isApprox(y))
{
cout << "Here is a solution x to the equation mx=... |
fde972fb080d2679672712a054666fdaa84ca7e65cb4ebd6be2491cc7691181f | C++ | 425 | 16 | /*
* This file is part of NAStJA.
*
* Copyright 2016 - 2021 Marco Berghoff and the NAStJA Core Developers
*
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
* distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#inc... |
ae774a7eb7027a7a8e6466b526c9548eb2d09c015944d0ab760730a9fdff8687 | C++ | 426 | 16 | /**************************************************************
* unit test driver
**************************************************************/
#include <cstring>
#include "common.hpp"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
if (argc>1 && (!std::strcmp(argv[1],"-v") || ... |
a6020bbead2149d6a7253559a64f460057dafbc5f205692817b5dfa5974a6285 | C++ | 427 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
try
{
// calling push_back() on a string value
json j = "string";
j.push_back("another string");
}
catch (json::type_error& e)
{
// output exception information
std::c... |
ab4c60330230bb35b8bd26507e22cf3d90100a825ba703954baa56434c3bb339 | C++ | 428 | 8 | cout << "Even spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,4).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,8).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,15).transpose() << endl;
cout << "Uneven spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,7).transpose() << endl;
cout <<... |
0a9b686b3fcbfb13573581e98deba9116f13da5129bae842c3a0db04e48e8684 | C++ | 429 | 19 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXf a = ArrayXf::Random(5);
a *= 2;
cout << "a =" << endl
<< a << endl;
cout << "a.abs() =" << endl
<< a.abs() << endl;
cout << "a.abs().sqrt() =" << endl
<< a.abs()... |
a196855a40a7ccd719b604cffac46e3d429762301304085d6c598f4361521db2 | C++ | 429 | 25 | #include <mpi.h>
#include "communication/mpi.hpp"
namespace arb {
namespace mpi {
ARB_ARBOR_API int rank(MPI_Comm comm) {
int r;
MPI_OR_THROW(MPI_Comm_rank, comm, &r);
return r;
}
ARB_ARBOR_API int size(MPI_Comm comm) {
int s;
MPI_OR_THROW(MPI_Comm_size, comm, &s);
return s;
}
ARB_ARBOR_API... |
68039d100ac97e9e927f5fb94610d612afc2de12a907f8057afbe4c31acd4581 | C++ | 432 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a binary value
json value = json::binary({1, 2, 3});
// create a binary_t
json::binary_t binary = {{4, 5, 6}};
// swap the object stored in the JSON value
value.swap(binary);
// output t... |
c4c97f0e1c0570ade90c52f8f16e97773f40b374bc6575ed9809b80c9f041dc5 | C++ | 432 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
try
{
// calling at() for a non-existing key
json j = {{"foo", "bar"}};
json k = j.at("non-existing");
}
catch (json::exception& e)
{
// output exception information
s... |
ad8ec4506c5e79c1246b3f2f4090adcb01f64fbca063bd9b9fba07ee498a5160 | C++ | 433 | 12 | /*!
* Copyright (c) 2021-2026 Microsoft Corporation. All rights reserved.
* Copyright (c) 2021-2026 The LightGBM developers. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
#include <gtest/gtest.h>
int main(int argc, char** argv) {
testing::... |
eec9d2ef9f8d0564bb448052ef627d0721c63e875ed9cbf1b620093c1fac3c9b | C++ | 433 | 20 | #include <iostream>
#include <string>
#include "util/unwind.hpp"
#include "util.hpp"
namespace arb {
namespace memory {
namespace util {
void log_error(const char* file, int line, const std::string& msg) {
std::cerr
<< arb::util::backtrace()
<< red("runtime error") << " @ "
<< white(file)... |
eee05d776e2bcff09727820fcc964d2620b6554539338159d6c9f3e47d43c26a | C++ | 433 | 20 | #include <Eigen/Dense>
#include <iostream>
using namespace std;
int main()
{
Eigen::MatrixXf m(4,4);
m << 1, 2, 3, 4,
5, 6, 7, 8,
9,10,11,12,
13,14,15,16;
cout << "Block in the middle" << endl;
cout << m.block<2,2>(1,1) << endl << endl;
for (int i = 1; i <= 3; ++i)
{... |
655055ec11e7938933303989aaa6ee47413fe7d4960915224b352d3202e0c986 | C++ | 435 | 9 | MatrixXd X = MatrixXd::Random(4,4);
MatrixXd A = X * X.transpose();
cout << "Here is a random positive-definite matrix, A:" << endl << A << endl << endl;
SelfAdjointEigenSolver<MatrixXd> es(A);
cout << "The inverse square root of A is: " << endl;
cout << es.operatorInverseSqrt() << endl;
cout << "We can also co... |
2696fca1389ce3d3651b4bb62f9458b88516bb15722e1e4ae3204d69888e13da | C++ | 436 | 18 | #include <iostream>
#include <Eigen/Core>
using namespace Eigen;
template <typename Derived>
void print_size(const EigenBase<Derived>& b)
{
std::cout << "size (rows, cols): " << b.size() << " (" << b.rows()
<< ", " << b.cols() << ")" << std::endl;
}
int main()
{
Vector3f v;
print_s... |
5d71e4791f54e1fa84a8ab419b2f908e6335e636c26c0b383281d54dfeb5c5ce | C++ | 438 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json value = { "the good", "the bad", "the ugly" };
// create string_t
json::string_t string = "the fast";
// swap the object stored in the JSON value
value[1].swap(string);
... |
1a24bf8d4c26b615ea3d48a16a3fef83e55af9456b9a0fa3d0fe3ccb69e94c2b | C++ | 439 | 10 | MatrixXd A = MatrixXd::Random(6,6);
cout << "Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
RealSchur<MatrixXd> schur(A);
cout << "The orthogonal matrix U is:" << endl << schur.matrixU() << endl;
cout << "The quasi-triangular matrix T is:" << endl << schur.matrixT() << endl << endl;
MatrixXd U ... |
62a3d2d17d3c7f4a6175ccd8ce2858ec06f2dabdec1e9fadef6d739b384dff19 | C++ | 439 | 9 | MatrixXd A = MatrixXd::Random(6,6);
cout << "Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
EigenSolver<MatrixXd> es(A);
MatrixXd D = es.pseudoEigenvalueMatrix();
MatrixXd V = es.pseudoEigenvectors();
cout << "The pseudo-eigenvalue matrix D is:" << endl << D << endl;
cout << "The pseudo-eigenvec... |
0f9d6c4febd1eaa93ca806e812ceb3b5b822caecca00183f3ca18d81b844a24d | C++ | 440 | 25 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json array = {1, 2, 3, 4, 5};
json null;
// print values
std::cout << array << '\n';
std::cout << null << '\n';
// add values
array.push_back(6);
array += 7;
null ... |
4211b918f808d5dbe38a544ce02b4847a9dff6d334168d0fc001c91849f305f2 | C++ | 441 | 17 | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Matrix4cd A = Matrix4cd::Random();
MatrixPower<Matrix4cd> Apow(A);
std::cout << "The matrix A is:\n" << A << "\n\n"
"A^3.1 is:\n" << Apow(3.1) << "\n\n"
"A^3.3 is:\n" << Apow(3.3) <<... |
bd8d907dd6898fa70ba9a43bc4451e25f0b457e6c67ec8b110ea049e115b8499 | C++ | 444 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json value = {{"array", {1, 2, 3, 4}}};
// create an array_t
json::array_t array = {"Snap", "Crackle", "Pop"};
// swap the array stored in the JSON value
value["array"].swap(arra... |
8ea9421025678b487efb96d972087b414b8452d5f22bb993f0f83371ec8580c8 | C++ | 450 | 16 | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(2,2);
A << cos(pi/3), -sin(pi/3),
sin(pi/3), cos(pi/3);
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix square ... |
4670da896fed37d3f8398f514796c37b08abf9db2b67ee8f4714b8c32e9cbc09 | C++ | 452 | 24 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json array = {1, 2, 3, 4, 5};
json null;
// print values
std::cout << array << '\n';
std::cout << null << '\n';
// add values
array.emplace_back(6);
null.emplace_back(... |
74dcba431a5fc44af2d7a9aa3e245ad6fe4ecf088058133f5c3338401651b116 | C++ | 454 | 11 | // __ _____ _____ _____
// __| | __| | | | JSON for Modern C++ (supporting code)
// | | |__ | | | | | | version 3.11.2
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// Copyright (c) 2013-2022 Niels Lohmann <http://nlohmann.me>.
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann... |
ce2349dac331630b36401b27c2ec25e4409317147546856ad8806b07dd6fa2b2 | C++ | 454 | 9 | MatrixXd X = MatrixXd::Random(5,5);
MatrixXd A = X + X.transpose();
cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl;
Tridiagonalization<MatrixXd> triOfA(A);
MatrixXd Q = triOfA.matrixQ();
cout << "The orthogonal matrix Q is:" << endl << Q << endl;
MatrixXd T = triOfA.matrixT();
cout... |
02f0ac22d40cf11d772be83baf4e7b25937269d45ddba189cd27965406668adf | C++ | 457 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
try
{
// parsing input with a syntax error
json::parse("[1,2,3,]");
}
catch (json::parse_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\... |
922da2bf80112d3fae4081795668a4697ba9bf9ec97fac2dd7104e117b3cb077 | C++ | 457 | 18 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// The fuzzer should find a leak in a non-main thread.
#include <cstdint>
#include <cstddef>
#include <thread>
static volatile int *Sink;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t... |
ff73884f57d8bfb8efb12018c37a77ac3fdace5482536c9087f3655981cafed9 | C++ | 457 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create two JSON objects
json j1 = {{"one", "eins"}, {"two", "zwei"}};
json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
// output objects
std::cout << j1 << '\n';
std::cout << j2 << '\n';
... |
4578d05b3665d3da1c5699bc5d73cd6a8aa859729cb01b9cff5ea0eacac7360b | C++ | 463 | 7 | GeneralizedEigenSolver<MatrixXf> ges;
MatrixXf A = MatrixXf::Random(4,4);
MatrixXf B = MatrixXf::Random(4,4);
ges.compute(A, B);
cout << "The (complex) numerators of the generalzied eigenvalues are: " << ges.alphas().transpose() << endl;
cout << "The (real) denominatore of the generalzied eigenvalues are: " << ges... |
b4e8401918fa1864075ae2859233b4422db6a8f4ab23579df48ec6b3ef1a292f | C++ | 464 | 24 | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Eigen::MatrixXf m(2,4);
Eigen::VectorXf v(2);
m << 1, 23, 6, 9,
3, 11, 7, 2;
v << 2,
3;
MatrixXf::Index index;
// find nearest neighbour
(m.colwise() - v).colw... |
dcd7d7c7dfcc6dc50a2edef9b15b3565f46d8c11812e462a66ead84177ad0b2a | C++ | 464 | 8 | typedef Matrix<float,Dynamic,2> DataMatrix;
// let's generate some samples on the 3D plane of equation z = 2x+3y (with some noise)
DataMatrix samples = DataMatrix::Random(12,2);
VectorXf elevations = 2*samples.col(0) + 3*samples.col(1) + VectorXf::Random(12)*0.1;
// and let's solve samples * [x y]^T = elevations in... |
0965a4ab2c82189347651fb446571903d7e6c62221e66ec7efd04f6c63d866fa | C++ | 465 | 18 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call count()
auto count_two = j_object.count("two");
auto count_three = j_object.count("three");
// print values
std::cout << "n... |
7e562e75c6dd403d6d589ea478dc080fcf97578e75611447c31b0c6dec4925eb | C++ | 465 | 17 | #include <Eigen/Dense>
#include <iostream>
using namespace std;
int main()
{
Eigen::Matrix4f m;
m << 1, 2, 3, 4,
5, 6, 7, 8,
9, 10,11,12,
13,14,15,16;
cout << "m.leftCols(2) =" << endl << m.leftCols(2) << endl << endl;
cout << "m.bottomRows<2>() =" << endl << m.bottomRows<2>(... |
ef4dc134de0be0c946d1bce867b7590b1d0d30e25fbb10674edf197f2221e53f | C++ | 465 | 18 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
MatrixXf m(2,2);
m << 1,-2,
-3,4;
cout << "1-norm(m) = " << m.cwiseAbs().colwise().sum().maxCoeff()
<< " == " << m.colwise().lpNorm<1>().maxCoeff() << endl;
cout <... |
05440c3830643b705612bd32140e459850b3848a86aa55e08b4193ec69c2e90c | C++ | 466 | 22 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
MatrixXf m(2,2);
MatrixXf n(2,2);
MatrixXf result(2,2);
m << 1,2,
3,4;
n << 5,6,
7,8;
result = (m.array() + 4).matrix() * m;
cout << "-- Combination 1: --" << endl << r... |
0d50b8307dedf94159a6d204df77bac296b6c70295ec63675460f3960ed26750 | C++ | 466 | 20 | #include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call erase()
auto count_one = j_object.erase("one"sv);
auto count_three... |
7ce40d77e80a0babff010adc26aa798bbb225a5eeeed92604590cbc32f844a40 | C++ | 466 | 26 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a valid JSON text
auto valid_text = R"(
{
"numbers": [1, 2, 3]
}
)";
// an invalid JSON text
auto invalid_text = R"(
{
"strings": ["extra", "comma", ]
}... |
9845921302012051b7a212a77c5703f24c4cf03e8d4189bf5dea65dceb18228a | C++ | 467 | 17 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Simple test for a fuzzer. The fuzzer must find a particular string.
#include <cstring>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data,... |
d639f7630cb81a5f779f0f85e90b70c4c4c46fb31e1ea6616c49982c96f0aa1e | C++ | 467 | 6 | Matrix3Xd M = Matrix3Xd::Random(3,5);
Projective3d P(Matrix4d::Random());
cout << "The matrix M is:" << endl << M << endl << endl;
cout << "M.colwise().homogeneous():" << endl << M.colwise().homogeneous() << endl << endl;
cout << "P * M.colwise().homogeneous():" << endl << P * M.colwise().homogeneous() << endl << e... |
77636df6e2df0e3574ceca0ee2e707e4cfc016a11e5873b2e09f6f47d8928af7 | C++ | 469 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
try
{
// calling iterator::key() on non-object iterator
json j = "string";
json::iterator it = j.begin();
auto k = it.key();
}
catch (json::invalid_iterator& e)
{
// o... |
7e01e57dad40d414f0c8c0775b8d7b5b6fdaa34d87c80af0d1960fd536a4bab1 | C++ | 470 | 17 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Simple test for a fuzzer. The fuzzer must find a particular string.
#include <cstring>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data,... |
ab5cf684bceee376c817481c20d7d54cc1fca93172e69085dd63640350ef6a67 | C++ | 471 | 17 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Simple test for a fuzzer. The fuzzer must find a particular string.
#include <cstring>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data,... |
aea10c60fea768b78b76a669bcc28ade3439a62df02f170c7abd4320a4bd882c | C++ | 472 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using std::to_string;
int main()
{
// create values
json j = {{"one", 1}, {"two", 2}};
int i = 42;
// use ADL to select best to_string function
auto j_str = to_string(j); // calling nlohmann::to_string
auto i_str =... |
901ded4a2189b62dcada9b719bbb65856d6c7c9ec2400711f3f07701cbdfb704 | C++ | 473 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON array
json v = {1, 2, 3, 4};
// create a JSON array to copy values from
json v2 = {"one", "two", "three", "four"};
// insert range from v2 before the end of array v
auto new_pos = v.in... |
44e70579e68644d30a89c5df890a504e9d3a6ab6b2e71dddd2d396d97b3d5639 | C++ | 474 | 16 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}};
nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}};
nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}};
nlo... |
ffc0fba6334298d0ec88488333179cb41bfe00b87541365bd96ea3cb7c597d4b | C++ | 476 | 15 | #include <tracing/systemclock.hpp>
#include <chrono>
#include <exception>
int64_t SystemClock::GetEpochMs() const
{
auto epoch = std::chrono::high_resolution_clock::now().time_since_epoch();
return std::chrono::duration_cast<std::chrono::milliseconds>(epoch).count();
}
int64_t SystemClock::GetEpochUs() const
{
... |
50f5f4c2a96c65206508563958d11bfcb25209ea494775e03b597840923a8f2c | C++ | 479 | 19 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Simple test for a fuzzer. The fuzzer must find the empty string.
#include <cstdint>
#include <cstdlib>
#include <cstddef>
#include <iostream>
static volatile int *Null = 0;
extern "C" int LLVMFuzzerTe... |
e0ad6684c6001504df3e97f34cce08957e8e6f04ca120b48c56c8e5d6c2acc70 | C++ | 479 | 12 | Matrix2f M = Matrix2f::Random();
Matrix2f m;
m = M;
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Now we want to copy a column into a row." << endl;
cout << "If we do m.col(1) = m.row(0), then m becomes:" << endl;
m.col(1) = m.row(0);
cout << m << endl << "which is wrong!" << endl;
cout << "Now... |
ae0a091987fc722b310592fe6fa63c66ab4c74e84dcd7f9e73f80d61e708bcb9 | C++ | 480 | 18 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Test for a fuzzer: must find the case where a particular basic block is
// executed many times.
#include <iostream>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
int Num =... |
c0838b9ff48c37563dcce00f2024b4314281ac34c8d96657d5574716a7ad8347 | C++ | 480 | 12 | Matrix3f m = Matrix3f::Random();
std::ptrdiff_t i, j;
float minOfM = m.minCoeff(&i,&j);
cout << "Here is the matrix m:\n" << m << endl;
cout << "Its minimum coefficient (" << minOfM
<< ") is at position (" << i << "," << j << ")\n\n";
RowVector4i v = RowVector4i::Random();
int maxOfV = v.... |
32582afadbefd03a7d5b732d92a80640a1048cdd220051f53adfc73a5f9b4840 | C++ | 483 | 25 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON array
json array = {1, 2, 3, 4, 5};
// output element at index 3 (fourth element)
std::cout << array[3] << '\n';
// change last element to 6
array[array.size() - 1] = 6;
// output... |
7f647aadfd1e5abdad2c12c773524169acecff8982096dc7bd9ef58c7810b059 | C++ | 483 | 12 | Matrix3i m = Matrix3i::Random();
cout << "Here is the initial matrix m:" << endl << m << endl;
int i = -1;
for(auto c: m.colwise()) {
c *= i;
++i;
}
cout << "Here is the matrix m after the for-range-loop:" << endl << m << endl;
auto cols = m.colwise();
auto it = std::find_if(cols.cbegin(), cols.cend(),
... |
4b1106afa229d1c239e9a48b0d6d7452d57eb5106d8fba70b648419ec61aa0a4 | C++ | 485 | 10 | MatrixXd X = MatrixXd::Random(5,5);
MatrixXd A = X + X.transpose();
cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl;
VectorXd diag(5);
VectorXd subdiag(4);
internal::tridiagonalization_inplace(A, diag, subdiag, true);
cout << "The orthogonal matrix Q is:" << endl << A << endl;
cou... |
1102aad2aefd340ecbe62fc248ad679fe971390eb98df662f6025db453ef2a77 | C++ | 489 | 22 | #include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
Eigen::Reshaped<Derived, 4, 2>
reshape_helper(MatrixBase<Derived>& m)
{
return Eigen::Reshaped<Derived, 4, 2>(m.derived());
}
int main(int, char**)
{
MatrixXd m(2, 4);
m << 1, 2, 3, 4,... |
7df9072ac5e1fbb18227353b3ceb570e50536b934b0bb5cfff0b024e952b225d | C++ | 489 | 20 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Simple test for a fuzzer: find the interesting argument for div.
#include <assert.h>
#include <cstdint>
#include <cstring>
#include <cstddef>
#include <iostream>
static volatile int Sink;
extern "C" i... |
706d60760a971231cef3772d66e516093fa31fc7e0a5e2245e57885673c2b725 | C++ | 490 | 24 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXXf m(2,2);
// assign some values coefficient by coefficient
m(0,0) = 1.0; m(0,1) = 2.0;
m(1,0) = 3.0; m(1,1) = m(0,1) + m(1,0);
// print values to standard output
cout << m << en... |
5a5e24870f58099453192cc832ba03acad33d0b5a20e77879ed719145d82bea1 | C++ | 491 | 9 | Matrix4d A = Matrix4d::Random(4,4);
cout << "Here is a random 4x4 matrix:" << endl << A << endl;
HessenbergDecomposition<Matrix4d> hessOfA(A);
Matrix4d pm = hessOfA.packedMatrix();
cout << "The packed matrix M is:" << endl << pm << endl;
cout << "The upper Hessenberg part corresponds to the matrix H, which is:"
... |
7737ddf5a3e33eaffc6ae377028dc3155cfb7e5b2f179c76c0f3168a472abd2d | C++ | 491 | 23 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON pointer
json::json_pointer ptr("/foo");
std::cout << "\"" << ptr << "\"\n";
// append a JSON Pointer
ptr /= json::json_pointer("/bar/baz");
std::cout << "\"" << ptr << "\"\n";
// a... |
ec4ff7f7f3d901f1a9c3804cd0992a334a071ab5eacc39249563f6f4a4a1b6fc | C++ | 492 | 21 | #include <thalamus/thread.hpp>
#ifdef _WIN32
#include <Windows.h>
#elif defined(__APPLE__)
#include <pthread.h>
#else
#include <sys/prctl.h>
#endif
namespace thalamus {
void set_current_thread_name(const std::string &name) {
#ifdef _WIN32
std::wstring wname(name.begin(), name.end());
SetThreadDescription(GetCurren... |
f968cd4ab9f57d4544146cdf7c0fb296be5c3873daae6ed0d0769dc790b8cb74 | C++ | 492 | 23 | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
std::complex<double> expfn(std::complex<double> x, int)
{
return std::exp(x);
}
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(3,3);
A << 0, -pi/4, 0,
pi/4, 0, 0,
0, 0... |
23e36e051f1fa2b0b0d4a7ec0a065caad695f33b4334ce57eaefa7091a62068f | C++ | 493 | 22 | #include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Matrix2d a;
a << 1, 2,
3, 4;
MatrixXd b(2,2);
b << 2, 3,
1, 4;
std::cout << "a + b =\n" << a + b << std::endl;
std::cout << "a - b =\n" << a - b << std::endl;
std::cout << "Doing a += b;" << std::... |
ae92458ef3f6aa4c5f8d6a3e83a58c61c7cc8ebe3f4d56067288b5e9ef51ea3f | C++ | 493 | 6 | Vector3d v = Vector3d::Random(), w;
Projective3d P(Matrix4d::Random());
cout << "v = [" << v.transpose() << "]^T" << endl;
cout << "h.homogeneous() = [" << v.homogeneous().transpose() << "]^T" << endl;
cout << "(P * v.homogeneous()) = [" << (P * v.... |
cbec03161db8a1deeefc41f5e2343202b8369343a19e97b386a2415c29083a97 | C++ | 494 | 20 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
// create an object_t
json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
// swap the object stored in th... |
92843866b332e7c8f15f65bb7921d4de2ce13c6a449b3901576e1f1693d6cead | C++ | 500 | 21 | // __ _____ _____ _____
// __| | __| | | | JSON for Modern C++ (supporting code)
// | | |__ | | | | | | version 3.11.2
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#includ... |
88ea60700a1a74b64f2b6b97d4063d1ad33e1e937898b31cbc964eed82e36a84 | C++ | 507 | 22 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to BSON
std::vector<std::uint8_t> v = json::to_bson(j);
// p... |
e4ebd4394c02ddc7e02019e8dc82866c55eb0ebac7708f2a569ba715d52d458a | C++ | 507 | 18 | #include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
MatrixXd m(2,5);
m.resize(4,3);
std::cout << "The matrix m is of size "
<< m.rows() << "x" << m.cols() << std::endl;
std::cout << "It has " << m.size() << " coefficients" << std::endl;
VectorXd v(2);
v.... |
ee43dba989728c9c2c0405f59517d7ea832f69f98b5ef3b862fc60ccae10e034 | C++ | 507 | 22 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to CBOR
std::vector<std::uint8_t> v = json::to_cbor(j);
// p... |
dcb7816deb93341a152e519671f373589307bfc19064a2972bcc84135c5f66b5 | C++ | 512 | 19 | #include "matlabexception.h"
// Function definitions for class MatlabException.
// -----------------------------------------------------------------
MatlabException::MatlabException (const char* message) throw()
: exception() {
this->message = message;
}
MatlabException::MatlabException (const MatlabException& s... |
c24daee0c35b4644253197ab2af8dbb560351c5031cb8987dccaac1917267593 | C++ | 513 | 32 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace ns
{
// a simple struct to model a person
struct person
{
std::string name;
std::string address;
int age;
};
} // namespace ns
namespace ns
{
void to_json(json& j, const person& p)
{
j = json{ {"name", p.name}, {"... |
2065d903b8fe45b4ef7a05adcfce363c5b7f703d6845ab41b0d76c6de112f7a3 | C++ | 514 | 23 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
// example for an object
for (auto& x : j_object.items())
{
std::cout << "key: " << x.key() << ",... |
c61883ce5255d95ecb27484beccfcad86419b6591a1d9f61d855aa14190fab3a | C++ | 516 | 19 | #define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/compatibility.hpp>
int main()
{
int Error(0);
Error += glm::isfinite(1.0f) ? 0 : 1;
Error += glm::isfinite(1.0) ? 0 : 1;
Error += glm::isfinite(-1.0f) ? 0 : 1;
Error += glm::isfinite(-1.0) ? 0 : 1;
Error += glm::all(glm::isfinite(glm::vec4(1.0f))) ? 0 : 1;
Err... |
539a11c185bb9c54260c100fa12f318b832310e29e1153ebfc3d388deaf2a241 | C++ | 517 | 22 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to MessagePack
std::vector<std::uint8_t> v = json::to_msgpack(j);... |
cc3b98165bf066418f34490a5b95f045471e0b6ea052c9ab9995ff880726f04f | C++ | 517 | 22 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <cstring>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
int Matches = 0;
for (size_t i = 0; i + 2 < Size; ... |
dae6123f9dc7273a825371d43a30fc3bc06b3aa085c99ca4e8d61eafd6a26632 | C++ | 522 | 20 | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
MatrixXf mat(2,4);
mat << 1, 2, 6, 9,
3, 1, 7, 2;
MatrixXf::Index maxIndex;
float maxNorm = mat.colwise().sum().maxCoeff(&maxIndex);
std::cout << "Maximum sum at position " << ma... |
68d367db8ad302c6619a3f7d1341daf8334ed9803e5c25d867bbbd844153b56f | C++ | 524 | 26 | #include <iostream>
#include <iomanip>
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create stream with serialized JSON
std::stringstream ss;
ss << R"({
"number": 23,
"string": "Hello, world!",
"array": [1, 2, 3, 4, 5],
"boolea... |
4b7f8656a9bc0efb527d54359819924326f1762697dcd0a704187079e2030df6 | C++ | 527 | 21 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// The test spams to stderr and stdout.
#include <assert.h>
#include <cstdint>
#include <cstdio>
#include <cstddef>
#include <iostream>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Si... |
5157508344774a6aacd10dcb1713daf9532d8d9d89d60e82a8f4c06f72c8f7f4 | C++ | 527 | 30 | // Cytosim was created by Francois Nedelec. Copyright 2007-2017 EMBL.
/*
This is a test of C++ extensions
defined by ISOC++11
http://en.wikipedia.org/wiki/C%2B%2B11
it should be compiled with icc -std=gnu++11
199711L
201103L
201300L
201402L
*/
#include <iostream>
int main ()
{
std::clog << "C++ ... |
fca27d4bd6940d3ccefb8aa7e6c5a4bb001bb68b29e626403fc3056494a706ce | C++ | 527 | 17 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Test with a more mallocs than frees, but no leak.
#include <cstdint>
#include <cstddef>
const int kAllocatedPointersSize = 10000;
int NumAllocatedPointers = 0;
int *AllocatedPointers[kAllocatedPointers... |
6e24655e877a7d5019e434c1b294659d6bbd1da0d9735ef2acfb1a936490449d | C++ | 528 | 20 | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
MatrixXd A = MatrixXd::Random(3,3);
std::cout << "A = \n" << A << "\n\n";
MatrixXd sinA = A.sin();
std::cout << "sin(A) = \n" << sinA << "\n\n";
MatrixXd cosA = A.cos();
std::cout << "cos(A... |
bd765fd22080c0c2efeaecdd217255a1b64b47c118ca7eb10d408582f3a107ee | C++ | 528 | 20 | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
void copyUpperTriangularPart(MatrixXf& dst, const MatrixXf& src)
{
dst.triangularView<Upper>() = src.triangularView<Upper>();
}
int main()
{
MatrixXf m1 = MatrixXf::Ones(4,4);
MatrixXf m2 = MatrixXf::Random(4,4);
std::cout << "m2... |
8cf656640e73d818e3dc3fcaf6fba4f7d2a7377ec70ac1b6cad814eaf5177bd1 | C++ | 529 | 30 | // Cytosim was created by Francois Nedelec. Copyright 2007-2017 EMBL.
#include "nucleus_prop.h"
#include "glossary.h"
void NucleusProp::clear()
{
stiffness = -1;
}
void NucleusProp::read(Glossary& glos)
{
glos.set(stiffness, "stiffness");
}
void NucleusProp::complete(Simul const& sim)
{
if ( st... |
7b5363202414e5b5e3ccaca44b9be2ca1cb1281a90e4ccef924c387b3b1b4fe6 | C++ | 530 | 7 | Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones());
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwiseAbs();
// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
cout << "Is (" << p0.transpose() << ") inside the box: "
<< ((boxMin.array()<p0.ar... |
2180abeed16c725be3d95b45e63769437ae16a81d6f8d005edd7d4820c9bd683 | C++ | 531 | 12 | MatrixXd A(3,3);
A << 4,-1,2, -1,6,0, 2,0,5;
cout << "The matrix A is" << endl << A << endl;
LLT<MatrixXd> lltOfA(A); // compute the Cholesky decomposition of A
MatrixXd L = lltOfA.matrixL(); // retrieve factor L in the decomposition
// The previous two lines can also be written as "L = A.llt().matrixL()"
co... |
4d28ceeeba8abba686198b6a2e7dc3865ff586ef67a00fa5dbd8e56b970f263d | C++ | 531 | 11 | Matrix3d m = Matrix3d::Zero();
m.triangularView<Eigen::Upper>().setOnes();
cout << "Here is the matrix m:\n" << m << endl;
Matrix3d n = Matrix3d::Ones();
n.triangularView<Eigen::Lower>() *= 2;
cout << "Here is the matrix n:\n" << n << endl;
cout << "And now here is m.inverse()*n, taking advantage of the fact that... |
63cd89380af2dc31869ea2eabc629ed90d44312b383c73934418f02c872adad0 | C++ | 532 | 19 | #include <fstream>
#include <utility>
#include <fmt/format.h>
#include <sup/ioutil.hpp>
namespace sup {
ARB_SUP_API std::fstream open_or_throw(const std::filesystem::path& p, std::ios_base::openmode mode, bool exclusive) {
if (exclusive && std::filesystem::exists(p)) throw std::runtime_error(fmt::format("file {... |
115bc118eefa65047013f592ea8e31b191c9f3634dc7e1f0a9ef0e4428992a07 | C++ | 533 | 28 | #include "../../source/first_blood.h"
#include <string>
using namespace std;
vector<double> vfr_bc(vector<double> t, double q_input_f);
int main(int argc, char* argv[])
{
// basic stuff
string case_folder = "models/";
string case_name = "Carotis_2";
if(argc == 2)
{
case_name = argv[1];
}
do... |
4f01d1168e8af09cd151060ec1f44150696c83d465ee7336abe3b7a5be177806 | C++ | 533 | 31 | #include <glm/glm.hpp>
int test_float_size()
{
return
sizeof(glm::float_t) != sizeof(glm::lowp_float) &&
sizeof(glm::float_t) != sizeof(glm::mediump_float) &&
sizeof(glm::float_t) != sizeof(glm::highp_float);
}
int test_float_precision()
{
return (
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
... |
42b31e0e53f6c375169347462e63fe0a09fedc7506c572f4c5d1a9d2a3b40a46 | C++ | 534 | 21 | #include <Eigen/Dense>
#include <iostream>
using namespace std;
using namespace Eigen;
int main()
{
ArrayXXf a(2,2);
a << 1,2,
3,4;
cout << "(a > 0).all() = " << (a > 0).all() << endl;
cout << "(a > 0).any() = " << (a > 0).any() << endl;
cout << "(a > 0).count() = " << (a > 0).... |
cce441c1200b08cdae77f7722bb8dfcc35e6cf5543a95a111344045eca709958 | C++ | 535 | 20 | #include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call count()
auto count_two = j_object.count("two"sv);
auto count_three... |
0417b19f8553e9ced3ab88dad52eeee292d06f9ef9c226ffe76ee3ff5ffa21f0 | C++ | 541 | 18 | #include <Eigen/Dense>
#include <iostream>
using namespace std;
using namespace Eigen;
int main()
{
Array22f m;
m << 1,2,
3,4;
Array44f a = Array44f::Constant(0.6);
cout << "Here is the array a:" << endl << a << endl << endl;
a.block<2,2>(1,1) = m;
cout << "Here is now a with m copied... |
93224b6b2d10c9ccfa7f07f9caa10f21a216e65b5f062b96b9804bb247d05282 | C++ | 542 | 27 | // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Tests -trace_malloc
#include <assert.h>
#include <cstdint>
#include <cstdlib>
#include <cstddef>
#include <iostream>
int *Ptr;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {... |
20f0425c10b03c4ebba7c7114e864a47468d5a345d2466968d3264f2a7e2c9f8 | C++ | 543 | 18 | Matrix<int, 3, 4, ColMajor> Acolmajor;
Acolmajor << 8, 2, 2, 9,
9, 1, 4, 4,
3, 5, 4, 5;
cout << "The matrix A:" << endl;
cout << Acolmajor << endl << endl;
cout << "In memory (column-major):" << endl;
for (int i = 0; i < Acolmajor.size(); i++)
cout << *(Acolmajor.data() + i) << " ";
co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.