📄 vslsminmaxestimator.c
字号:
/*******************************************************************************! INTEL CONFIDENTIAL! Copyright(C) 2007-2008 Intel Corporation. All Rights Reserved.! The source code contained or described herein and all documents related to! the source code ("Material") are owned by Intel Corporation or its suppliers! or licensors. Title to the Material remains with Intel Corporation or its! suppliers and licensors. The Material contains trade secrets and proprietary! and confidential information of Intel or its suppliers and licensors. The! Material is protected by worldwide copyright and trade secret laws and! treaty provisions. No part of the Material may be used, copied, reproduced,! modified, published, uploaded, posted, transmitted, distributed or disclosed! in any way without Intel's prior express written permission.! No license under any patent, copyright, trade secret or other intellectual! property right is granted to or conferred upon you by disclosure or delivery! of the Materials, either expressly, by implication, inducement, estoppel or! otherwise. Any license under such intellectual property rights must be! express and approved by Intel in writing.!!*******************************************************************************! Content:! Calculation of min/max estimates Example Program Text!******************************************************************************/#include "mkl.h"#include "vsl_ss.h"#include "stdio.h"#define RETURN_ON_ERROR \ if(errcode<0) \ { \ printf("Error: %i\n", errcode); \ printf("\nTEST FAILED\n"); \ return 0; \ }#define SEED 777#define BRNG VSL_BRNG_MCG31#define METHOD 0#define DIM 3 /* dimension of the task */ #define N 1000 /* number of observations */int main(){ VSLSSTaskPtr task=0; VSLStreamStatePtr stream; int dim=DIM, n=N, storage=VSL_SS_MATRIX_COLUMNS_STORAGE; float x[N][DIM]; /* matrix of observations */ float min_estimator[DIM], max_estimator[DIM]; float a=0.0,sigma=1.0; int errcode; int i,j,fail; for(i=0;i<DIM;i++) min_estimator[i]=max_estimator[i]=0; /***** Initialize *****/ errcode = vslNewStream( &stream, BRNG, SEED ); /***** Call RNG *****/ errcode = vsRngGaussian( METHOD, stream, N*DIM, (float*)x, a, sigma ); /***** Deinitialize *****/ errcode = vslDeleteStream( &stream ); errcode = vslsSSNewTask( &task, &dim, &n, &storage, (float*)x, 0, 0 ); RETURN_ON_ERROR; errcode = vslsSSEditTask( task, VSL_SS_MIN_ARRAY, min_estimator ); RETURN_ON_ERROR; errcode = vslsSSEditTask( task, VSL_SS_MAX_ARRAY, max_estimator ); RETURN_ON_ERROR; errcode = vslsSSCompute(task, VSL_SS_MIN|VSL_SS_MAX, VSL_SS_FAST_METHOD ); RETURN_ON_ERROR; errcode = vslSSDeleteTask( &task ); RETURN_ON_ERROR; printf(" Min Max\n"); for(i=0;i<DIM;i++) { printf("Variable #%i: %+f %+f\n", i, min_estimator[i], max_estimator[i]); } for(i=0;i<DIM;i++) { for(j=0;j<N;j++) { if(x[j][i] < min_estimator[i]) fail++; if(x[j][i] > max_estimator[i]) fail++; } } printf("\nTEST PASSED\n"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -