📄 vslspartialcovariance.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 correlation matrix Example Program Text!******************************************************************************/#include "mkl.h"#include "vsl_ss.h"#include <stdio.h>#define N 1000 /* number of observations */#define DIM 4 /* dimension of the task */ #define PART_DIM (DIM/2) /* dimension of partial cov */ #define RETURN_ON_ERROR \ if(errcode<0) \ { \ printf("Error: %i\n", errcode); \ printf("\nTEST FAILED\n"); \ return errcode; \ }int main(){ int i, j; int dim=DIM; VSLSSTaskPtr task=0; float cov[DIM][DIM]; MKL_INT cov_storage = VSL_SS_MATRIX_FULL_STORAGE; MKL_INT partial_index[DIM]; float partial_cov[PART_DIM][PART_DIM]; MKL_INT partial_cov_storage = VSL_SS_MATRIX_FULL_STORAGE; MKL_INT errcode; for(i=0;i<DIM;i++) { partial_index[i]=(i<PART_DIM)? 1 : -1; for(j=0;j<DIM;j++) { cov[i][j]=(i==j)?(1.0):(0.1); } } for(i=0;i<PART_DIM;i++) { for(j=0;j<PART_DIM;j++) { partial_cov[i][j]=0.0; } } errcode = vslsSSNewTask( &task, &dim, 0, 0, 0, 0, 0 ); RETURN_ON_ERROR; cov_storage = VSL_SS_MATRIX_FULL_STORAGE; errcode = vslsSSEditPartialCovCor( task, (int*)partial_index, (float*)cov, &cov_storage, 0, 0, (float*)partial_cov, &partial_cov_storage, 0, &partial_cov_storage ); RETURN_ON_ERROR; errcode = vslsSSCompute( task, VSL_SS_PARTIAL_COVARIANCE, VSL_SS_FAST_METHOD ); RETURN_ON_ERROR; errcode = vslSSDeleteTask( &task ); RETURN_ON_ERROR; printf(" Dimension of the task: %d\n", DIM); printf("Number of observations: %d\n\n", N); printf(" Covariance matrix\n"); for(i=0;i<DIM;i++) { for(j=0;j<DIM;j++) { printf("%+f ", cov[i][j]); } printf("\n"); } printf("\n"); printf(" Computed partial covariance matrix\n"); for(i=0;i<PART_DIM;i++) { for(j=0;j<PART_DIM;j++) { printf("%+9f ", partial_cov[i][j]); } printf("\n"); } printf("\nTEST PASSED\n"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -