diff --git a/content/3rd-party-libs.ipynb b/content/3rd-party-libs.ipynb
index 19c59e8..062e51d 100644
--- a/content/3rd-party-libs.ipynb
+++ b/content/3rd-party-libs.ipynb
@@ -28,6 +28,12 @@
"source": "## Scientific Computation (Symbolic & Numeric)\n\nLet’s begin with powerful C++ libraries for symbolic math, high-precision arithmetic, and efficient numerical computation using BLAS and LAPACK routines.",
"metadata": {}
},
+ {
+ "id": "0c0e79fc-65ce-4efa-8bf9-a20125d347a1",
+ "cell_type": "markdown",
+ "source": "1. [boost-cpp](https://github.com/boostorg/boost): Collection of peer-reviewed portable C++ libraries for tasks like linear algebra, multithreading, networking, parsing, and more.\n2. [symengine](https://github.com/symengine/symengine): Fast C++ symbolic mathematics library supporting algebraic manipulation, calculus, equation solving, and more, with optional Python bindings.",
+ "metadata": {}
+ },
{
"id": "7ef2ba09-bcc8-41e2-b503-3b21e60fdd3e",
"cell_type": "code",
@@ -92,6 +98,18 @@
],
"execution_count": 4
},
+ {
+ "id": "6b7e64a2-546c-47a7-b4ed-95e98febd785",
+ "cell_type": "markdown",
+ "source": "## Array based Computation through Xtensor-stack\n\nExplore NumPy-style array computing in C++ with Xtensor, Xtensor-BLAS, and Xsimd — enabling high-performance numerical and SIMD-accelerated workflows.",
+ "metadata": {}
+ },
+ {
+ "id": "d640a780-ead3-4f8f-a2d9-f21c38990456",
+ "cell_type": "markdown",
+ "source": "1. [openblas](https://github.com/xianyi/OpenBLAS): Optimized BLAS and LAPACK implementation providing efficient linear algebra routines such as matrix multiplication, factorization, and solvers.\n2. [xtensor](https://github.com/xtensor-stack/xtensor): C++ multidimensional array library with NumPy-like syntax, enabling numerical computing, broadcasting, and integration with C++ scientific libraries.\n3. [xtensor-blas](https://github.com/xtensor-stack/xtensor-blas): BLAS and LAPACK bindings for xtensor, adding high-performance linear algebra operations like dot products, decompositions, and solvers.\n4. [xsimd](https://github.com/xtensor-stack/xsimd): C++ library providing a high-level SIMD API that abstracts platform-specific vectorization instructions, simplifying portable and efficient numerical code.\n",
+ "metadata": {}
+ },
{
"id": "f25ec9b7-951e-4494-b932-64d71a601127",
"cell_type": "code",
@@ -109,10 +127,23 @@
"execution_count": 5
},
{
- "id": "6b7e64a2-546c-47a7-b4ed-95e98febd785",
- "cell_type": "markdown",
- "source": "## Array based Computation through Xtensor-stack\n\nExplore NumPy-style array computing in C++ with Xtensor, Xtensor-BLAS, and Xsimd — enabling high-performance numerical and SIMD-accelerated workflows.",
- "metadata": {}
+ "id": "c5275c44-c5a8-4ae4-9221-7149f37a545a",
+ "cell_type": "code",
+ "source": "?xt::xtensor",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/html": "\n ",
+ "text/plain": "https://xtensor.readthedocs.io/en/latest/api/xtensor.html#_CPPv2N2xt7xtensorE"
+ },
+ "metadata": {}
+ }
+ ],
+ "execution_count": 6
},
{
"id": "6496d5e7-d1e5-4437-be87-bb26b48ce735",
@@ -130,7 +161,7 @@
"metadata": {}
}
],
- "execution_count": 6
+ "execution_count": 7
},
{
"id": "c748227d-4083-4c19-8f07-a449d41e67fe",
@@ -148,7 +179,7 @@
"metadata": {}
}
],
- "execution_count": 7
+ "execution_count": 8
},
{
"id": "74298554-9964-4633-bff3-e67d03a1797d",
@@ -158,7 +189,7 @@
"trusted": true
},
"outputs": [],
- "execution_count": 8
+ "execution_count": 9
},
{
"id": "22dadb84-d39e-4028-a919-febd64f4a60d",
@@ -193,7 +224,7 @@
"metadata": {}
}
],
- "execution_count": 9
+ "execution_count": 10
},
{
"id": "d8e9e9e7-5def-4d77-b459-afb8002282ae",
@@ -209,7 +240,7 @@
"text": "(3.300000, 7.700000, 12.100000, 16.500000)\n"
}
],
- "execution_count": 10
+ "execution_count": 11
},
{
"id": "0f0978c4-7ec4-4615-894a-c6558503d851",
@@ -217,6 +248,12 @@
"source": "## Interactive Widgets\n\nBuild rich, interactive UI components in C++ using xwidgets and xcanvas, seamlessly integrated with the Jupyter frontend.",
"metadata": {}
},
+ {
+ "id": "8965d8ed-5704-47a2-806a-c047f542782d",
+ "cell_type": "markdown",
+ "source": "1. [xwidgets](https://github.com/jupyter-xeus/xwidgets): C++ implementation of the Jupyter widget protocol, providing core interactive widgets and serving as the foundation for libraries like xleaflet and xcanvas.\n2. [xcanvas](https://github.com/jupyter-xeus/xcanvas): C++ library bringing the HTML5 canvas API to Jupyter via the widget protocol, enabling interactive 2D graphics and visualizations in notebooks.",
+ "metadata": {}
+ },
{
"id": "2ce27d4d-43f7-464c-a611-5400c3cdb735",
"cell_type": "code",
@@ -225,7 +262,7 @@
"trusted": true
},
"outputs": [],
- "execution_count": 11
+ "execution_count": 12
},
{
"id": "36b1b0f7-00d9-47bf-8543-985e27088d07",
@@ -235,7 +272,7 @@
"trusted": true
},
"outputs": [],
- "execution_count": 12
+ "execution_count": 13
},
{
"id": "b2647bb5-0c2e-4f12-b0ed-0c0f5c7ed65c",
@@ -249,16 +286,16 @@
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "07f19b34aac74f97947e4e9b068ebe5f",
+ "model_id": "2f0bf4f323ea4ccdb9337a9115e4320d",
"version_major": 2,
"version_minor": 1
},
- "text/plain": "A Jupyter widget with unique id: 07f19b34aac74f97947e4e9b068ebe5f"
+ "text/plain": "A Jupyter widget with unique id: 2f0bf4f323ea4ccdb9337a9115e4320d"
},
"metadata": {}
}
],
- "execution_count": 13
+ "execution_count": 14
},
{
"id": "0f3e4dcb-5d9f-479b-b568-8d7625683946",
@@ -268,7 +305,7 @@
"trusted": true
},
"outputs": [],
- "execution_count": 14
+ "execution_count": 15
},
{
"id": "1eed2b39-b632-440c-9d3d-c8d377bc504c",
@@ -278,7 +315,7 @@
"trusted": true
},
"outputs": [],
- "execution_count": 15
+ "execution_count": 16
},
{
"id": "4d1797e5-3ce1-4737-9561-a87a7e82cce1",
@@ -292,16 +329,141 @@
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "e34c45cc453240cebac33426cd7c448d",
+ "model_id": "39f80e8c2a204499bc095f1defdce65f",
"version_major": 2,
"version_minor": 1
},
- "text/plain": "A Jupyter widget with unique id: e34c45cc453240cebac33426cd7c448d"
+ "text/plain": "A Jupyter widget with unique id: 39f80e8c2a204499bc095f1defdce65f"
},
"metadata": {}
}
],
- "execution_count": 16
+ "execution_count": 17
+ },
+ {
+ "id": "ed69c0cd-c65a-47d7-9ee2-13502953e876",
+ "cell_type": "code",
+ "source": "#include \n\nint width2 = 400;\nint height2 = 400;\n\nauto canvas2 = xc::canvas().initialize()\n .width(width2)\n .height(height2)\n .finalize();\n\nusing canvas2_type = std::decay_t;\n\nxcpp::display(canvas2);\n\nstruct Context2\n{\n canvas2_type *canvas = nullptr;\n int iter = 0;\n int stop = 100000;\n int width = 400;\n int height = 400;\n\n // the on_mouse_move callbacks would set these\n int mouse_pos_x = 200;\n int mouse_pos_y = 200;\n int mouse_is_down = 0;\n};\n\nvoid callback2(void* arg) {\n Context2 &ctx = *reinterpret_cast(arg);\n\n if (ctx.iter >= ctx.stop)\n {\n emscripten_cancel_main_loop();\n }\n\n // clear the canvas\n ctx.canvas->clear_rect(0, 0, ctx.width, ctx.height);\n\n std::stringstream color_ss;\n color_ss << \"rgba(\" << (ctx.iter % 255) << \", \"\n << (ctx.iter * 2 % 255) << \", \"\n << (ctx.iter * 3 % 255) << \", 0.5)\";\n\n // draw a circle at the mouse position\n ctx.canvas->begin_path();\n ctx.canvas->arc(ctx.mouse_pos_x, ctx.mouse_pos_y,\n 5 + (ctx.iter / 3) % 20, 0, 2 * M_PI);\n ctx.canvas->fill_style = color_ss.str();\n ctx.canvas->fill();\n\n ctx.iter++;\n}\n\n// type of the callback\nusing xy_callback_type2 = std::function;\n\nContext2 ctx2{};\nauto ctx2_ptr = &ctx2;\n\nxy_callback_type2 cb2_on_mouse_move([](int x, int y) {\n ctx2_ptr->mouse_pos_x = x;\n ctx2_ptr->mouse_pos_y = y;\n});\n\nxy_callback_type2 cb2_on_mouse_down([](int x, int y) {\n ctx2_ptr->mouse_is_down = 1;\n ctx2_ptr->mouse_pos_x = x;\n ctx2_ptr->mouse_pos_y = y;\n});\n\nxy_callback_type2 cb2_on_mouse_up([](int x, int y) {\n ctx2_ptr->mouse_is_down = 0;\n ctx2_ptr->mouse_pos_x = x;\n ctx2_ptr->mouse_pos_y = y;\n});\n\nxy_callback_type2 cb2_on_mouse_leave([](int x, int y) {\n ctx2_ptr->mouse_is_down = 0;\n ctx2_ptr->mouse_pos_x = x;\n ctx2_ptr->mouse_pos_y = y;\n});\n\ncanvas2.on_mouse_move(cb2_on_mouse_move);\ncanvas2.on_mouse_down(cb2_on_mouse_down);\ncanvas2.on_mouse_up(cb2_on_mouse_up);\ncanvas2.on_mouse_leave(cb2_on_mouse_leave);\n\nctx2.canvas = &canvas2;\nctx2.width = width2;\nctx2.height = height2;\n\nvoid* void_ctx2 = reinterpret_cast(&ctx2);\nemscripten_set_main_loop_arg(callback2, void_ctx2, 0, false);",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "a33b74e244e04db2931d1992de9e2817",
+ "version_major": 2,
+ "version_minor": 1
+ },
+ "text/plain": "A Jupyter widget with unique id: a33b74e244e04db2931d1992de9e2817"
+ },
+ "metadata": {}
+ }
+ ],
+ "execution_count": 18
+ },
+ {
+ "id": "1587e911-0786-4353-9211-264f78691a62",
+ "cell_type": "markdown",
+ "source": "## Magic Commands\n\nMagics are special commands assisting code execution for the user. Specific to the kernel and are not a part of the C++ programming language.\n\nThere are defined with the symbol % for a line magic and %% for a cell magic.",
+ "metadata": {}
+ },
+ {
+ "id": "2178c1d9-2193-49b6-906b-55492099470f",
+ "cell_type": "markdown",
+ "source": "1. `%%file`: Open, read, write to a file. \n2. `%mamba`: Fetch packages from emscripten-forge at runtime.",
+ "metadata": {}
+ },
+ {
+ "id": "fb1d314e-647c-487e-ac44-d685c2c1bb28",
+ "cell_type": "code",
+ "source": "%%file tmp.txt\nDemo of magic command",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": "Writing tmp.txt\n"
+ }
+ ],
+ "execution_count": 19
+ },
+ {
+ "id": "e400940c-c374-4a88-a9f5-6410ff80f170",
+ "cell_type": "code",
+ "source": "%%file -a tmp.txt\nappend at the end",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": "Appending to tmp.txt\n"
+ }
+ ],
+ "execution_count": 20
+ },
+ {
+ "id": "057d0380-cbc0-4eb6-b996-3acb8f3ba631",
+ "cell_type": "code",
+ "source": "#include \n\nstd::ifstream infile(\"tmp.txt\");\nstd::string line;\nwhile (std::getline(infile, line)) {\n std::cout << line << std::endl;\n}\ninfile.close();",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": "Demo of magic command\nappend at the end\n"
+ }
+ ],
+ "execution_count": 21
+ },
+ {
+ "id": "a7d04714-7ced-4f68-98f4-118ce32ac745",
+ "cell_type": "code",
+ "source": "%mamba install doctest",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": "Specs: xeus-cpp, symengine, xtensor-blas, xsimd, xwidgets, xcanvas, doctest\nChannels: https://repo.prefix.dev/emscripten-forge-dev, conda-forge\n\nSolving environment...\nSolving took 7.976399999976159 seconds\n Name Version Build Channel \n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\u001b[0;32m+ doctest \u001b[0m2.4.12 h2072262_0 https://repo.prefix.dev/emscripten-forge-dev/\n\u001b[0;31m- pip \u001b[0m25.2 pyh145f28c_0 conda-forge \n"
+ }
+ ],
+ "execution_count": 22
+ },
+ {
+ "id": "f5430288-b6d9-4648-a603-d555a847e9df",
+ "cell_type": "code",
+ "source": "#define DOCTEST_CONFIG_IMPLEMENT\n#include \n\nTEST_CASE(\"Simple check\") {\n CHECK(1 == 2);\n}\n\nint main() {\n doctest::Context context;\n context.setOption(\"success\", true); // Show successful tests\n return context.run();\n}",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [],
+ "execution_count": 23
+ },
+ {
+ "id": "19c66056-adfb-4618-aba1-38c3ea45afc7",
+ "cell_type": "code",
+ "source": "main();",
+ "metadata": {
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": "[doctest] doctest version is \"2.4.12\"\n[doctest] run with \"--help\" for options\n===============================================================================\ninput_line_21:4:\nTEST CASE: Simple check\n\ninput_line_21:5: ERROR: CHECK( 1 == 2 ) is NOT correct!\n values: CHECK( 1 == 2 )\n\n===============================================================================\n[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped\n[doctest] assertions: 1 | 0 passed | 1 failed |\n[doctest] Status: FAILURE!\n"
+ }
+ ],
+ "execution_count": 24
},
{
"id": "d26a70d2-9dc6-4ca0-b974-2cfd4249a8a7",
@@ -323,10 +485,10 @@
"text": "{\n \"age\": 30,\n \"is_student\": false,\n \"name\": \"John Doe\",\n \"skills\": [\n \"C++\",\n \"Python\",\n \"JavaScript\"\n ]\n}\n"
}
],
- "execution_count": 17
+ "execution_count": 25
},
{
- "id": "ed69c0cd-c65a-47d7-9ee2-13502953e876",
+ "id": "a9b6c51a-6202-46f6-99ac-c18d24b09549",
"cell_type": "code",
"source": "",
"metadata": {