CSI-DSP  Version 1.0.0
CSI DSP Software Library
csky_class_marks_example_f32.c
/* ----------------------------------------------------------------------
* Copyright (C) 2016-2016 CSKY Limited. All rights reserved.
*
* Project: CSI DSP Library
* Title: csky_class_marks_example_f32.c
*
* Description: Example code to calculate Minimum, Maximum
* Mean, std and variance of marks obtained in a class
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the name of CSKY LIMITED nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* -------------------------------------------------------------------- */
#include "csky_math.h"
#define USE_STATIC_INIT
/* ----------------------------------------------------------------------
** 全局定义
** ------------------------------------------------------------------- */
#define TEST_LENGTH_SAMPLES (20*4)
/* ----------------------------------------------------------------------
** 罗列了20名学生4门课的成绩
** ------------------------------------------------------------------- */
{
42.000000, 37.000000, 81.000000, 28.000000,
83.000000, 72.000000, 36.000000, 38.000000,
32.000000, 51.000000, 63.000000, 64.000000,
97.000000, 82.000000, 95.000000, 90.000000,
66.000000, 51.000000, 54.000000, 42.000000,
67.000000, 56.000000, 45.000000, 57.000000,
67.000000, 69.000000, 35.000000, 52.000000,
29.000000, 81.000000, 58.000000, 47.000000,
38.000000, 76.000000, 100.000000, 29.000000,
33.000000, 47.000000, 29.000000, 50.000000,
34.000000, 41.000000, 61.000000, 46.000000,
52.000000, 50.000000, 48.000000, 36.000000,
47.000000, 55.000000, 44.000000, 40.000000,
100.000000, 94.000000, 84.000000, 37.000000,
32.000000, 71.000000, 47.000000, 77.000000,
31.000000, 50.000000, 49.000000, 35.000000,
63.000000, 67.000000, 40.000000, 31.000000,
29.000000, 68.000000, 61.000000, 38.000000,
31.000000, 28.000000, 28.000000, 76.000000,
55.000000, 33.000000, 29.000000, 39.000000
};
/* ----------------------------------------------------------------------
* 测试的学科数量 X 1
* ------------------------------------------------------------------- */
{
1.000, 1.000, 1.000, 1.000
};
/* ----------------------------------------------------------------------
** f32 输出缓存
** ------------------------------------------------------------------- */
/* ------------------------------------------------------------------
* 全局定义
*------------------------------------------------------------------- */
#define NUMSTUDENTS 20
#define NUMSUBJECTS 4
/* ------------------------------------------------------------------
* 全局变量
*------------------------------------------------------------------- */
uint32_t numStudents = 20;
uint32_t numSubjects = 4;
uint32_t student_num;
/* ----------------------------------------------------------------------------------
* 测试f32类型的函数
* ------------------------------------------------------------------------------- */
int32_t main()
{
#ifndef USE_STATIC_INIT
/* 初始化输入输出矩阵 */
#else
/* 静态初始化输入输出矩阵大小和数组 */
#endif
/* ----------------------------------------------------------------------
* 调用矩阵乘法处理函数
* ------------------------------------------------------------------- */
csky_mat_mult_f32(&srcA, &srcB, &dstC);
/* ----------------------------------------------------------------------
** 调用最大值函数计算最高分
** ------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
** 调用最小值函数计算最低分
** ------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
** 调用平均值函数取平均值
** ------------------------------------------------------------------- */
csky_mean_f32(testOutput, numStudents, &mean);
/* ----------------------------------------------------------------------
** 调用标准差函数求标准差
** ------------------------------------------------------------------- */
csky_std_f32(testOutput, numStudents, &std);
/* ----------------------------------------------------------------------
** 调用方差函数求方差
** ------------------------------------------------------------------- */
csky_var_f32(testOutput, numStudents, &var);
while(1); /* main函数不会返回 */
}