CMSIS DSP Software Library: arm_class_marks_example_f32.c Source File
Main Page
Modules
Data Structures
Files
Examples
File List
Globals
arm_class_marks_example_f32.c
Go to the documentation of this file.00001 /* ----------------------------------------------------------------------
00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
00003 *
00004 * $Date: 29. November 2010
00005 * $Revision: V1.0.3
00006 *
00007 * Project: CMSIS DSP Library
00008 * Title: arm_class_marks_example_f32.c
00009 *
00010 * Description: Example code to calculate Minimum, Maximum
00011 * Mean, std and variance of marks obtained in a class
00012 *
00013 * Target Processor: Cortex-M4/Cortex-M3
00014 *
00015 * Version 1.0.3 2010/11/29
00016 * Re-organized the CMSIS folders and updated documentation.
00017 *
00018 * Version 1.0.1 2010/10/05 KK
00019 * Production release and review comments incorporated.
00020 *
00021 * Version 1.0.0 2010/09/20 KK
00022 * Production release and review comments incorporated.
00023 * ------------------------------------------------------------------- */
00024
00067 #include "arm_math.h"
00068
00069 #define USE_STATIC_INIT
00070
00071 /* ----------------------------------------------------------------------
00072 ** Global defines
00073 ** ------------------------------------------------------------------- */
00074
00075 #define TEST_LENGTH_SAMPLES (20*4)
00076
00077 /* ----------------------------------------------------------------------
00078 ** List of Marks scored by 20 students for 4 subjects
00079 ** ------------------------------------------------------------------- */
00080 const float32_t testMarks_f32[TEST_LENGTH_SAMPLES] =
00081 {
00082 42.000000, 37.000000, 81.000000, 28.000000,
00083 83.000000, 72.000000, 36.000000, 38.000000,
00084 32.000000, 51.000000, 63.000000, 64.000000,
00085 97.000000, 82.000000, 95.000000, 90.000000,
00086 66.000000, 51.000000, 54.000000, 42.000000,
00087 67.000000, 56.000000, 45.000000, 57.000000,
00088 67.000000, 69.000000, 35.000000, 52.000000,
00089 29.000000, 81.000000, 58.000000, 47.000000,
00090 38.000000, 76.000000, 100.000000, 29.000000,
00091 33.000000, 47.000000, 29.000000, 50.000000,
00092 34.000000, 41.000000, 61.000000, 46.000000,
00093 52.000000, 50.000000, 48.000000, 36.000000,
00094 47.000000, 55.000000, 44.000000, 40.000000,
00095 100.000000, 94.000000, 84.000000, 37.000000,
00096 32.000000, 71.000000, 47.000000, 77.000000,
00097 31.000000, 50.000000, 49.000000, 35.000000,
00098 63.000000, 67.000000, 40.000000, 31.000000,
00099 29.000000, 68.000000, 61.000000, 38.000000,
00100 31.000000, 28.000000, 28.000000, 76.000000,
00101 55.000000, 33.000000, 29.000000, 39.000000
00102 };
00103
00104
00105 /* ----------------------------------------------------------------------
00106 * Number of subjects X 1
00107 * ------------------------------------------------------------------- */
00108 const float32_t testUnity_f32[4] =
00109 {
00110 1.000, 1.000, 1.000, 1.000
00111 };
00112
00113
00114 /* ----------------------------------------------------------------------
00115 ** f32 Output buffer
00116 ** ------------------------------------------------------------------- */
00117 static float32_t testOutput[TEST_LENGTH_SAMPLES];
00118
00119
00120 /* ------------------------------------------------------------------
00121 * Global defines
00122 *------------------------------------------------------------------- */
00123 #define NUMSTUDENTS 20
00124 #define NUMSUBJECTS 4
00125
00126 /* ------------------------------------------------------------------
00127 * Global variables
00128 *------------------------------------------------------------------- */
00129
00130 uint32_t numStudents = 20;
00131 uint32_t numSubjects = 4;
00132 float32_t max_marks, min_marks, mean, std, var;
00133 uint32_t student_num;
00134
00135 /* ----------------------------------------------------------------------------------
00136 * Main f32 test function. It returns maximum marks secured and student number
00137 * ------------------------------------------------------------------------------- */
00138
00139 int32_t main()
00140 {
00141
00142 #ifndef USE_STATIC_INIT
00143
00144 arm_matrix_instance_f32 srcA;
00145 arm_matrix_instance_f32 srcB;
00146 arm_matrix_instance_f32 dstC;
00147
00148 /* Input and output matrices initializations */
00149 arm_mat_init_f32(&srcA, numStudents, numSubjects, (float32_t *)testMarks_f32);
00150 arm_mat_init_f32(&srcB, numSubjects, 1, (float32_t *)testUnity_f32);
00151 arm_mat_init_f32(&dstC, numStudents, 1, testOutput);
00152
00153 #else
00154
00155 /* Static Initializations of Input and output matrix sizes and array */
00156 arm_matrix_instance_f32 srcA = {NUMSTUDENTS, NUMSUBJECTS, (float32_t *)testMarks_f32};
00157 arm_matrix_instance_f32 srcB = {NUMSUBJECTS, 1, (float32_t *)testUnity_f32};
00158 arm_matrix_instance_f32 dstC = {NUMSTUDENTS, 1, testOutput};
00159
00160 #endif
00161
00162
00163 /* ----------------------------------------------------------------------
00164 *Call the Matrix multiplication process function
00165 * ------------------------------------------------------------------- */
00166 arm_mat_mult_f32(&srcA, &srcB, &dstC);
00167
00168 /* ----------------------------------------------------------------------
00169 ** Call the Max function to calculate max marks among numStudents
00170 ** ------------------------------------------------------------------- */
00171 arm_max_f32(testOutput, numStudents, &max_marks, &student_num);
00172
00173 /* ----------------------------------------------------------------------
00174 ** Call the Min function to calculate min marks among numStudents
00175 ** ------------------------------------------------------------------- */
00176 arm_min_f32(testOutput, numStudents, &min_marks, &student_num);
00177
00178 /* ----------------------------------------------------------------------
00179 ** Call the Mean function to calculate mean
00180 ** ------------------------------------------------------------------- */
00181 arm_mean_f32(testOutput, numStudents, &mean);
00182
00183 /* ----------------------------------------------------------------------
00184 ** Call the std function to calculate standard deviation
00185 ** ------------------------------------------------------------------- */
00186 arm_std_f32(testOutput, numStudents, &std);
00187
00188 /* ----------------------------------------------------------------------
00189 ** Call the var function to calculate variance
00190 ** ------------------------------------------------------------------- */
00191 arm_var_f32(testOutput, numStudents, &var);
00192
00193 }
00194
00195
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Mon Nov 29 2010 17:19:55 for CMSIS DSP Software Library by
1.7.2
Wyszukiwarka
Podobne podstrony:
arm class marks example ?2?arm linear interp example ?2? sourcearm class marks example?2? examplearm signal converge example ?2? sourcearm sin cos example ?2? sourcearm sin cos example ?2? sourcearm ?t bin example ?2? sourcearm dotproduct example ?2? sourcearm fir example ?2? sourcearm convolution example ?2? sourcearm variance example ?2? sourcearm matrix example ?2? sourcearm iir lattice init ?2? sourcearm biquad ?scade ?1 ?2? sourcearm cmplx mag squared ?2? sourcearm ?ft radix4 init ?2? sourcearm cmplx mult cmplx ?2? sourcearm fir interpolate init ?2? sourcearm ?t bin example ?2?więcej podobnych podstron