Interactive torch C++ for Data Analysis
This repo stores my personal C++ notes for learning torch C++.
Good introduction to start with interatctive C++: On-the-fly-C++
It's definitely true.
It’s not perfect but can be a real timesaver when fooling around with C or C++ code. Especially for little bits and pieces you want to try out while working on a C/C++ codebase, it’s much less distracting to fire up a cling interpreter than to setup an example project.
- Easy way to install via conda: use xeus-cling
conda create -n cling
conda activate cling
conda install xeus-cling -c conda-forge
#register the kernelspec for C++17/C++14/C++11:
#the user can install whichever kernel(s) they
#wish:
cd ${MINICONDA}/envs/cling/share/Jupyter/kernel
$ jupyter-kernelspec install [--user] xcpp17
$ jupyter-kernelspec install [--user] xcpp14
$ jupyter-kernelspec install [--user] xcpp11
- Use latest
Cling
only:
- You have to install Cling first.
- Excecute the following CMD to add C++ kernel to the Jupyter envrionment:
$ export PATH=/cling-install-prefix/bin:$PATH
$ cd /cling-install-prefix/share/cling/Jupyter/kernel
$ pip install -e .
#or: pip3 install -e .
#register the kernelspec for C++17/C++14/C++11:
#the user can install whichever kernel(s) they
#wish:
$ jupyter-kernelspec install [--user] cling-cpp17
$ jupyter-kernelspec install [--user] cling-cpp14
$ jupyter-kernelspec install [--user] cling-cpp11
After installation, start jupyter notebook and play. Some usefull tips when using cling in jupyter are summaried in the notebook 0.Introduction...
C++ Example:
#include<iostream>
int arr[3] = { 1, 2, 3};
int(&ra)[3](arr);
for (auto data: ra)//C++11
{
data = i + 5;
std::cout << data << std::endl;
}
std::cout << &arr << &ra << std::endl;
C Example:
#include<stdio.h>
int num=5;
int *p= #
int func(int a)
{
printf("%d",a);
}
int (*pFunc)(int a) = func;
printf("%d,%p", num, p);