Created
April 7, 2015 06:01
-
-
Save shu223/b68bd4360eeb1b93b86e to your computer and use it in GitHub Desktop.
Accelerate.frameworkを用いた平均値計算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TTMArithmetic.m | |
// | |
// Copyright (c) 2015 Shuichi Tsutsumi. All rights reserved. | |
// | |
#import "TTMArithmetic.h" | |
@import Accelerate; | |
@implementation MOSArithmetic | |
- (double)mean:(NSArray *)values { | |
double x[[values count]]; | |
for (int i=0; i<[values count]; i++) { | |
x[i] = [values[i] doubleValue]; | |
} | |
double result = 0.0; | |
vDSP_meanvD(x, 1, &result, (vDSP_Length)[values count]); | |
return result; | |
} | |
- (float)meanf:(NSArray *)values { | |
float x[[values count]]; | |
for (int i=0; i<[values count]; i++) { | |
x[i] = [values[i] floatValue]; | |
} | |
float result = 0.0; | |
vDSP_meanv(x, 1, &result, (vDSP_Length)[values count]); | |
return result; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment