| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /******************************************************************************
- * Copyright 2020 The Firmament Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *****************************************************************************/
- #ifndef LIGHT_MATRIX__
- #define LIGHT_MATRIX__
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "rtthread.h"
- #include "stddef.h"
- #define MAT_TYPE float
- #define MAT_MALLOC rt_malloc
- #define MAT_FREE rt_free
- #define MAT_PRINTF rt_kprintf
- #define MAT_ASSERT RT_ASSERT
- enum {
- MAT_EOK = 0, /**< There is no error */
- MAT_ERROR, /**< A generic error happens */
- MAT_ETIMEOUT, /**< Timed out */
- MAT_EFULL, /**< The resource is full */
- MAT_EEMPTY, /**< The resource is empty */
- MAT_ENOMEM, /**< No memory */
- MAT_ENOSYS, /**< No system */
- MAT_EBUSY, /**< Busy */
- MAT_EIO, /**< IO error */
- MAT_EINTR, /**< Interrupted system call */
- MAT_EINVAL, /**< Invalid argument */
- };
- typedef struct {
- size_t row, col;
- MAT_TYPE** element;
- MAT_TYPE* buffer;
- } Mat;
- /**
- * @brief 创建一个 mat 对象
- *
- * @param row mat 行数
- * @param col mat 列数
- * @return Mat* 返回 mat 对象指针, NULL 表示创建失败
- */
- Mat* MatNew(int row, int col);
- /**
- * @brief 释放 mat 对象
- *
- * @param mat
- */
- void MatDelete(Mat* mat);
- void MatInit(Mat *mat, int row, int col, MAT_TYPE *pdata);
- int MatSetVal(Mat* mat, MAT_TYPE* val);
- void MatDump(const Mat* mat);
- int MatZeros(Mat* mat);
- int MatEye(Mat* mat);
- int MatAdd(Mat* src1, Mat* src2, Mat* dst);
- int MatSub(Mat* src1, Mat* src2, Mat* dst);
- int MatMul(Mat* src1, Mat* src2, Mat* dst);
- int MatTrans(Mat* src, Mat* dst);
- MAT_TYPE MatDet(Mat* mat);
- int MatAdj(Mat* src, Mat* dst);
- MAT_TYPE MatNorm(Mat* mat);
- int MatEig(Mat* mat, MAT_TYPE* eig_val, Mat* eig_vec, MAT_TYPE eps, int njt);
- int MatCopy(Mat* src, Mat* dst);
- int MatLuDecomp(Mat* const matIn, Mat* matL, Mat* matU, Mat* matP);
- int MatInvByLu(Mat* const A, Mat* inv);
- int MatInv(Mat *src, Mat *dst);
- #ifdef __cplusplus
- }
- #endif
- #endif
|