---
title: "complexConstant(realPart:imaginaryPart:shape:dataType:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/complexconstant(realpart:imaginarypart:shape:datatype:)"
---

# complexConstant(realPart:imaginaryPart:shape:dataType:)

Creates a complex constant op with a given shape and returns the result tensor.

## Declaration

```swift
func complexConstant(realPart: Double, imaginaryPart: Double, shape: [NSNumber], dataType: MPSDataType) -> MPSGraphTensor
```

## Parameters

- `realPart`: The real part of the complex scalar to fill the entire tensor values with.
- `imaginaryPart`: The imaginary part of the complex scalar to fill the entire tensor values with.
- `shape`: The shape of the output tensor. This has to be statically shaped.
- `dataType`: The dataType of the constant tensor.

## Return Value

Return Value A valid MPSGraphTensor object.
