Code Monkey home page Code Monkey logo

matrixfeatures's Introduction

MatrixFeatures

Extract Matrix features

文件与目录

文件与目录的含义为:

  • doc/:该目录下包括一系列文件
    • features.pdf:记录了需要提取的特征
    • assignment-vs-move-assignment.png:对比是否添加move函数的效果
  • sparsemat.cpp sparsemat.h:定义基础数据结构的程序,包括稀疏矩阵基类,派生类COO和派生类CSR
  • tensor.cpp tensor.h:定义稠密矩阵的相关类,目前只定义了向量类Vec,以后可以派生出矩阵类,以及更高维的张量类
  • features.cpp features.h:基于稀疏矩阵类,定义的特征提取类程序
  • base.h:定义了全局宏,目前只是用INTDOUBLE来分别代替intdouble,后续可能会加上一些公用函数
  • main.cpp:程序的入口,进行具体操作
  • test.cpp:测试部分功能的程序
  • Makefile:编译的命令,使用make main即可编译出可执行程序
  • json.hpp:实现json的相关程序,具体介绍在下面
  • matrix.dat:小规模的COO矩阵数据,用于测试
  • main_features.json:运行./main生成的json文件

编程规范

  • 对于类名与函数名,使用驼峰命名法;对于变量名,使用下划线连接。比如,函数名为PrintCSRByRow(),变量名为input_file
  • 特别地,对于特征提取的函数,因为要加上编号,所以可以通过下划线连接。比如程序中包括的一个示例程序Features_1_1_Nrows(),其中编号对应features.pdf文件中的特征1.1,后面的Nrows表示特征的名称
  • 缩进统一使用tab,四个空格
  • 括号的使用,尽量对齐。比如
for(...)
{
	i++
}

不要使用下面这种方式

for(...){
	i++
}
  • 在头文件*.h中进行函数声明,在*.cpp中进行函数定义,尽量不要在头文件中进行函数实现

程序的主体已经写好,剩下的工作主要是:根据函数Features_1_1_Nrows()写法,基于CSR矩阵结构,编写出提取其它特征的函数。该函数的相关内容位于features.cpp features.h文件中。

json 库

考虑到STLmapunordered_map都没有输出到文件的功能,所以使用标准json库。可供选择的库有很多,例如:

  • rapidjson:速度最快,但是接口难用,没必要选择它;
  • jsoncpp:需要单独编译成库,再链接,麻烦;
  • nlohmann/json:只需一个hpp文件,接口设计的比较易用,整体评价也不错。

对性能的要求不高,越易用越好,所以最终选择nlohmann/json。用法很简单,只需要在官方网站 github:nlohmann/json 中下载json.hpp文件到本地,放在本工程目录下,然后在相关文件中加上

#include "json.hpp"

即可。

以上内容只是介绍,程序已经配置好了,不用再关心这部分内容。

matrixfeatures's People

Contributors

zhf-0 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.