/
lyapdy
/
skillbox_controllers
Обзор
Документация
Войти
/
lyapdy
/
skillbox_controllers
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Project7/lib/c_api.cpp
51 строка
812 B
danillyapunov
Second commit
09 дек 2025, 18:41
09 дек 2025, 18:41
2c9c8f9
Код
Авторство
О чём код?
#include "c_api.h" #include "matrix.h" struct Matrix : public math::Matrix { Matrix(const math::Matrix &M) : math::Matrix(M) {} }; extern "C" { Matrix* math_createMatrix(int rows, int cols) { return new Matrix(math::Matrix(rows, cols)); } void math_deleteMatrix(Matrix* M) { delete M; } double math_get(const Matrix* M, int row, int col) { return (*M)(row, col); } void math_set(Matrix* M, int row, int col, double val) { (*M)(row, col) = val; } Matrix* math_add(const Matrix* A, const Matrix* B) { return new Matrix(*A + *B); } Matrix* math_subtract(const Matrix* A, const Matrix* B) { return new Matrix(*A - *B); } Matrix* math_dot(const Matrix* A, const Matrix* B) { return new Matrix(*A * *B); } void math_print(const Matrix* M) { M->print(); } } // extern "C"