Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何从CGFloat数组创建CIVector?_Ios_Xcode_Swift_Cifilter_Unsafe Pointers - Fatal编程技术网

Ios 如何从CGFloat数组创建CIVector?

Ios 如何从CGFloat数组创建CIVector?,ios,xcode,swift,cifilter,unsafe-pointers,Ios,Xcode,Swift,Cifilter,Unsafe Pointers,我正在尝试在Swift中创建Cicross多项式过滤器类型 但是,我不确定如何创建语法来执行此操作 文档指定了一个具有浮点数组的CIVector A CIVector object whose display name is RedCoefficients. Default value: [1 0 0 0 0 0 0 0 0 0] Identity: [1 0 0 0 0 0 0 0 0 0] 但我该如何声明这样一个CIVector呢?有一个构造函数具有此签名 CIVector(values

我正在尝试在Swift中创建Cicross多项式过滤器类型

但是,我不确定如何创建语法来执行此操作

文档指定了一个具有浮点数组的CIVector

A CIVector object whose display name is RedCoefficients.

Default value: [1 0 0 0 0 0 0 0 0 0] Identity: [1 0 0 0 0 0 0 0 0 0]
但我该如何声明这样一个CIVector呢?有一个构造函数具有此签名

CIVector(values: <UnsafePointer<CGFloat>>, count: <UInt>)
CIVector(值:,计数:)
但是当我尝试的时候

var floatArr:Array<CGFloat> = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: floatArr.count)
var floatArr:Array=[1,0,0,0,0,0,0]
var vector=CIVector(值:floatArr,计数:floatArr.count)
我得到一个错误:

Cannot invoke 'init' with an argument list type (values: @lvaue Array<CGFloat>, count:Int)
无法使用参数列表类型调用“init”(值:@lvaue数组,计数:Int)

您知道如何正确地创建带有CGfloat数组的CIVector吗?

floatArr.count
的类型为
Int
,但
count:
参数的类型为
UInt
, 因此,您需要显式转换它:

let floatArr: [CGFloat] = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: UInt(floatArr.count))