0001 http://mattt.me)
0023 import Accelerate
0024
0025
0027 public func sincos(x: [Float]) -> (sin: [Float], cos: [Float]) {
0028 var sin = [Float](count: x.count, repeatedValue: 0.0)
0029 var cos = [Float](count: x.count, repeatedValue: 0.0)
0030 vvsincosf(&sin, &cos, x, [Int32(x.count)])
0031
0032 return (sin, cos)
0033 }
0034
0035 public func sincos(x: [Double]) -> (sin: [Double], cos: [Double]) {
0036 var sin = [Double](count: x.count, repeatedValue: 0.0)
0037 var cos = [Double](count: x.count, repeatedValue: 0.0)
0038 vvsincos(&sin, &cos, x, [Int32(x.count)])
0039
0040 return (sin, cos)
0041 }
0042
0043
0045 public func sin(x: [Float]) -> [Float] {
0046 var results = [Float](count: x.count, repeatedValue: 0.0)
0047 vvsinf(&results, x, [Int32(x.count)])
0048
0049 return results
0050 }
0051
0052 public func sin(x: [Double]) -> [Double] {
0053 var results = [Double](count: x.count, repeatedValue: 0.0)
0054 vvsin(&results, x, [Int32(x.count)])
0055
0056 return results
0057 }
0058
0059
0061 public func cos(x: [Float]) -> [Float] {
0062 var results = [Float](count: x.count, repeatedValue: 0.0)
0063 vvcosf(&results, x, [Int32(x.count)])
0064
0065 return results
0066 }
0067
0068 public func cos(x: [Double]) -> [Double] {
0069 var results = [Double](count: x.count, repeatedValue: 0.0)
0070 vvcos(&results, x, [Int32(x.count)])
0071
0072 return results
0073 }
0074
0075
0077 public func tan(x: [Float]) -> [Float] {
0078 var results = [Float](count: x.count, repeatedValue: 0.0)
0079 vvtanf(&results, x, [Int32(x.count)])
0080
0081 return results
0082 }
0083
0084 public func tan(x: [Double]) -> [Double] {
0085 var results = [Double](count: x.count, repeatedValue: 0.0)
0086 vvtan(&results, x, [Int32(x.count)])
0087
0088 return results
0089 }
0090
0091
0093 public func asin(x: [Float]) -> [Float] {
0094 var results = [Float](count: x.count, repeatedValue: 0.0)
0095 vvasinf(&results, x, [Int32(x.count)])
0096
0097 return results
0098 }
0099
0100 public func asin(x: [Double]) -> [Double] {
0101 var results = [Double](count: x.count, repeatedValue: 0.0)
0102 vvasin(&results, x, [Int32(x.count)])
0103
0104 return results
0105 }
0106
0107
0109 public func acos(x: [Float]) -> [Float] {
0110 var results = [Float](count: x.count, repeatedValue: 0.0)
0111 vvacosf(&results, x, [Int32(x.count)])
0112
0113 return results
0114 }
0115
0116 public func acos(x: [Double]) -> [Double] {
0117 var results = [Double](count: x.count, repeatedValue: 0.0)
0118 vvacos(&results, x, [Int32(x.count)])
0119
0120 return results
0121 }
0122
0123
0125 public func atan(x: [Float]) -> [Float] {
0126 var results = [Float](count: x.count, repeatedValue: 0.0)
0127 vvatanf(&results, x, [Int32(x.count)])
0128
0129 return results
0130 }
0131
0132 public func atan(x: [Double]) -> [Double] {
0133 var results = [Double](count: x.count, repeatedValue: 0.0)
0134 vvatan(&results, x, [Int32(x.count)])
0135
0136 return results
0137 }
0138
0139
0141
0143 func rad2deg(x: [Float]) -> [Float] {
0144 var results = [Float](count: x.count, repeatedValue: 0.0)
0145 let divisor = [Float](count: x.count, repeatedValue: Float(M_PI / 180.0))
0146 vvdivf(&results, x, divisor, [Int32(x.count)])
0147
0148 return results
0149 }
0150
0151 func rad2deg(x: [Double]) -> [Double] {
0152 var results = [Double](count: x.count, repeatedValue: 0.0)
0153 let divisor = [Double](count: x.count, repeatedValue: M_PI / 180.0)
0154 vvdiv(&results, x, divisor, [Int32(x.count)])
0155
0156 return results
0157 }
0158
0159
0161 func deg2rad(x: [Float]) -> [Float] {
0162 var results = [Float](count: x.count, repeatedValue: 0.0)
0163 let divisor = [Float](count: x.count, repeatedValue: Float(180.0 / M_PI))
0164 vvdivf(&results, x, divisor, [Int32(x.count)])
0165
0166 return results
0167 }
0168
0169 func deg2rad(x: [Double]) -> [Double] {
0170 var results = [Double](count: x.count, repeatedValue: 0.0)
0171 let divisor = [Double](count: x.count, repeatedValue: 180.0 / M_PI)
0172 vvdiv(&results, x, divisor, [Int32(x.count)])
0173
0174 return results
0175 }
0176