GithubHelp home page GithubHelp logo

ixcpp's Introduction

IXCpp

Interactive torch C++ for Data Analysis

This repo stores my personal C++ notes for learning torch C++.

Learning C++ in Jupyter Notebook

Good introduction to start with interatctive C++: On-the-fly-C++

Why use Cling in Jupyter

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.

Cling short tutorial

Cling-cpp-interpreter

Install C++ kernel for Jupyter Notebook

  1. 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
  1. 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

Run Example

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= &num;

    int func(int a)
    {
        printf("%d",a);
    }

    int (*pFunc)(int a) = func;

    printf("%d,%p", num, p);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.