C/C++ language and Rust

Digital Transformation Artificial Intelligence  Mathematics Algorithms and Data Structure Machine Learning Technology Programming Navigation of this blog

About C/C++ language and various machine learning algorithms

The C/C++ language is a programming language used in applications on many platforms, from microcomputers to large computers C is a very simple, flexible, and fast-running programming language based on structured programming, and C ++ adds the concept of object-oriented programming to the C language.

Both C and C++ compile (translate) programs written in high-level languages into machine language and then execute them, using gcc and g++ as compilers respectively.

For example, if you have the following program

// adder.cpp
#include<dstdio>

int main(){
   int a, b;
   scanf("%d %d", &a, &b);
   printf("%dn", a+b);
   return 0;
}

Compile as command

$ g++ adder.cpp

and if there is an error in the program, an error message is output; if there is no error, a file named a.out is generated and

$ ./a.out

When this file is executed as described above, the program waits for input from the standard input (keyboard), and when two integers are input, it outputs the result of the addition and terminates the program.

This C++ is also used as a generic program to describe various algorithms. Generic programming is a programming technique that appeared in the 1980s, and the C++ TL (Standard Template Library) was developed in the 1990s. Here, generic programming is a programming technique that focuses on designing algorithms and data structures to make them work in the most common environment without reducing efficiency.

Generic programming will be more like an attitude toward programming than a specific collection of tools represented by STL.

Generic programming has its origins in mathematics, or more specifically, in a branch of mathematics called abstract algebra. To help you understand this approach, this book describes abstract algebra with a focus on the technique of reasoning about objects in terms of the operations that can be performed on them.

Rust is a programming language for systems programming developed by Mozilla Research and designed to emphasize high performance, memory safety, parallelism, and multi-threaded processing. The language also focuses on bug prevention through strong static type checking at compile time.

In this blog, we will give a brief overview of these C/C++ and Rust.

General

  • Overview of Code as Data and Examples of Algorithms and Implementations

“Code as Data” refers to a concept or approach that treats the code of a program itself as data, and is a method that allows programs to be manipulated, analyzed, transformed, and processed as data structures. Normally, a program receives an input, executes a specific procedure or algorithm on it, and outputs the result. In “Code as Data,” on the other hand, the program itself is treated as data and manipulated by other programs. This allows programs to be handled more flexibly, dynamically, and abstractly.

C language Implementation

In order to program, it is necessary to create a development environment for each language. This section describes how to set up specific development environments for Python, Clojure, C, Java, R, LISP, Prolog, Javascript, and PHP, as described in this blog. Each language has its own platform to facilitate development, which makes it possible to easily set up the environment, but this section focuses on the simplest case.

File input/output functions are the most basic and indispensable functions when programming. Since file input/output functions are procedural instructions, each language has its own way of implementing them. Concrete implementations of file input/output in various languages are described below.

Among programming languages, the basic functionality is one element of the three functions of structured languages (1) sequential progression, (2) conditional branching, and (3) repetition, as described in the “History of Programming Languages” section. Here, we show implementations of repetition and branching in various languages.

This section describes examples of how servers described in “Server Technology” can be used in various programming languages. Server technology here refers to technology related to the design, construction, and operation of server systems that receive requests from clients over a network, execute requested processes, and return responses.

Server technologies are used in a variety of systems and services, such as web applications, API servers, database servers, and mail servers. Server technology implementation methods and best practices differ depending on the programming language and framework.

C implementation of the Metropolis method, one of the MCMC methods.

Simulations using the Metropolis method were conducted as an implementation in C. The method was applied to the superposition of two Gaussian distributions and the superposition of a semicircle and a Gaussian distribution, and the relationship between the number of steps and the simulation results was discussed.

As an implementation of the MCMC method using C, the multivariable case will be discussed, and the caveats and new algorithms that arise from the multivariable case will be described.

We will discuss HMC (Hybrid Monte Calro or Hamiltonian Monte Carlo), an algorithm other than the Metropolis method, as an implementation using C.

Gibbs sampling and MH methods are described as C-based implementations.

Bayesian estimation in C-based implementations will be described.

Applications such as Ising, combinatorial optimization, and particle physics in C-based implementations will be described.

Graph algorithms using C (strongly connected component decomposition, DAG, 2-SAT, LCA)

Basic algorithms for graph data using C (DFS, BFS, bipartite graph decision, shortest path problem, minimum global tree)

Algorithm for network flow problem using C

WoT (Web of Things) will be a standardized architecture and protocol for interconnecting various devices on the Internet and enabling communication and interaction between devices. The WoT is intended to extend the Internet of Things (IoT), simplify interactions with devices, and increase interoperability.

This article describes general implementation procedures, libraries, platforms, and concrete examples of WoT implementations in python and C.

Overview/Reference Book

Introduction to C/C++ Programming with Online Judge

Generic Programming

The theme of the book is programming, but unlike most programming books, in addition to algorithms and code, it includes mathematical proofs and historical background on mathematical discoveries from ancient times to the present.To be more specific, the theme is generic programming. Generic programming is a programming technique that emerged in the 1980s, with the development of the Standard Template Library (TL) in C++ in the 1990s. Here, generic programming is a programming technique that focuses on designing algorithms and data structures to make them work in the most common environment without reducing efficiency.Generic programming will be more like an attitude toward programming than a specific collection of tools represented by STL.

Rust

Rust is a programming language developed by Mozilla Research for systems programming, designed with an emphasis on high performance, memory safety, parallelism, and multi-threaded processing. It is also a language focused on bug prevention through strong static type checking at compile time.

This section provides an overview of Rust, its basic syntax, various applications, and concrete implementations.

Typically, IOT devices are small devices with sensors and actuators, and use wireless communication to collect sensor data and control actuators. Various communication protocols and technologies are used for wireless IoT control. This section describes examples of IoT implementations using this wireless technology in various languages.

The gradient method is one of the widely used methods in machine learning and optimization algorithms, whose main goal is to iteratively update parameters in order to find the minimum (or maximum) value of a function. In machine learning, the goal is usually to minimize the cost function (also called loss function). For example, in regression and classification problems, a cost function is defined to represent the error between predicted and actual values, and it helps to find the parameter values that minimize this cost function.

This section describes various algorithms for this gradient method and examples of implementations in various languages.

    コメント

    Exit mobile version
    タイトルとURLをコピーしました