@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveByteArray ( )

{ <EOL> val array = byteArrayOf ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getByteArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive ByteArray
 * and checks if the array's ByteArray representation matches the input ByteArray.
 */


@ Test <EOL> fun createByte3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Byte > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { ( it + <NUM_LIT:3> ) . toByte ( ) } <EOL> val expected = byteArrayOf ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getByteArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's ByteArray representation matches the expected output.
 */


@ Test <EOL> fun createByte3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> ( i * j + k ) . toByte ( ) } <EOL> val expected = byteArrayOf ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getByteArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's ByteArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedByte3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf < Byte > ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf < Byte > ( <NUM_LIT:8> ) ) , listOf ( listOf < Byte > ( <NUM_LIT:4> , <NUM_LIT:7> ) ) ) <EOL> val expected = listOf ( listOf ( listOf < Byte > ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf < Byte > ( <NUM_LIT:8> , <NUM_LIT:0> ) ) , listOf ( listOf < Byte > ( <NUM_LIT:4> , <NUM_LIT:7> ) , listOf < Byte > ( <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> val a : D3Array < Byte > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }

/**
 * Tests the function 'createAlignedNDArray' that creates a three-dimensional array from a list of number lists.
 * The test asserts that:
 * - The output array's size matches the size of the longest list in the input
 * and all lists are filled to match this length.
 * - The lists shorter than the longest one are filled with the specified filling value.
 */


@ Test <EOL> fun createZeroFilledShortArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < Short > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:0> . toShort ( ) } } <EOL> }

/**
 * This method checks if a short array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createShortArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < Short > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:1> . toShort ( ) } } <EOL> }

/**
 * Creates a short array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromShortList ( )

{ <EOL> val list = <EOL> listOf ( listOf ( listOf < Short > ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf < Short > ( <NUM_LIT:7> , <NUM_LIT:8> ) ) , listOf ( listOf < Short > ( <NUM_LIT:4> , <NUM_LIT:7> ) , listOf < Short > ( <NUM_LIT:9> , <NUM_LIT:2> ) ) ) <EOL> val a : D3Array < Short > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of short lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> @ Ignore <EOL> fun createThreeDimensionalArrayFromShortSet ( )

{ <EOL> val set = setOf < Short > ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:5> , <NUM_LIT:11> , <NUM_LIT> , - <NUM_LIT:8> , - <NUM_LIT:1> ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < Short > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of shorts
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveShortArray ( )

{ <EOL> val array = shortArrayOf ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getShortArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive ShortArray
 * and checks if the array's ShortArray representation matches the input ShortArray.
 */


@ Test <EOL> fun createShort3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Short > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { ( it + <NUM_LIT:3> ) . toShort ( ) } <EOL> val expected = shortArrayOf ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getShortArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's ShortArray representation matches the expected output.
 */


@ Test <EOL> fun createShort3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> ( i * j + k ) . toShort ( ) } <EOL> val expected = shortArrayOf ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getShortArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's ShortArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedShort3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf < Short > ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf < Short > ( <NUM_LIT:8> ) ) , listOf ( listOf < Short > ( <NUM_LIT:4> , <NUM_LIT:7> ) ) ) <EOL> val expected = listOf ( listOf ( listOf < Short > ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf < Short > ( <NUM_LIT:8> , <NUM_LIT:0> ) ) , listOf ( listOf < Short > ( <NUM_LIT:4> , <NUM_LIT:7> ) , listOf < Short > ( <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> val a : D3Array < Short > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }


@ Test <EOL> fun createZeroFilledIntArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < Int > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:0> } } <EOL> }

/**
 * This method checks if an integer array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createIntArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < Int > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:1> } } <EOL> }

/**
 * Creates an integer array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromIntList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf ( <NUM_LIT:7> , <NUM_LIT:8> ) ) , listOf ( listOf ( <NUM_LIT:4> , <NUM_LIT:7> ) , listOf ( <NUM_LIT:9> , <NUM_LIT:2> ) ) ) <EOL> val a : D3Array < Int > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of integer lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromIntSet ( )

{ <EOL> val set = setOf ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:5> , <NUM_LIT:11> , <NUM_LIT> , - <NUM_LIT:8> , - <NUM_LIT:1> ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < Int > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of integers
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveIntArray ( )

{ <EOL> val array = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getIntArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive IntArray
 * and checks if the array's IntArray representation matches the input IntArray.
 */


@ Test <EOL> fun createInt3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Int > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { ( it + <NUM_LIT:3> ) } <EOL> val expected = intArrayOf ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getIntArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's IntArray representation matches the expected output.
 */


@ Test <EOL> fun createInt3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k } <EOL> val expected = intArrayOf ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getIntArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's IntArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedInt3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf ( <NUM_LIT:8> ) ) , listOf ( listOf ( <NUM_LIT:4> , <NUM_LIT:7> ) ) ) <EOL> val expected = listOf ( listOf ( listOf ( <NUM_LIT:1> , <NUM_LIT:3> ) , listOf ( <NUM_LIT:8> , <NUM_LIT:0> ) ) , listOf ( listOf ( <NUM_LIT:4> , <NUM_LIT:7> ) , listOf ( <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> val a : D3Array < Int > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }


@ Test <EOL> fun createZeroFilledLongArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < Long > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:0L> } } <EOL> }

/**
 * This method checks if a long array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createLongArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < Long > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:1L> } } <EOL> }

/**
 * Creates a long array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromLongList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1L> , <NUM_LIT:3L> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) ) <EOL> val a : D3Array < Long > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of long lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromLongSet ( )

{ <EOL> val set = setOf ( <NUM_LIT:1L> , <NUM_LIT:3L> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT:1L> ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < Long > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of longs
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveLongArray ( )

{ <EOL> val array = longArrayOf ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getLongArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive LongArray
 * and checks if the array's LongArray representation matches the input LongArray.
 */


@ Test <EOL> fun createLong3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Long > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { it + <NUM_LIT:3L> } <EOL> val expected = longArrayOf ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getLongArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's LongArray representation matches the expected output.
 */


@ Test <EOL> fun createLong3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices < Long > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k . toLong ( ) } <EOL> val expected = longArrayOf ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getLongArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's LongArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedLong3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1L> , <NUM_LIT:3L> ) , listOf ( <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) ) ) <EOL> val expected = listOf ( listOf ( listOf ( <NUM_LIT:1L> , <NUM_LIT:3L> ) , listOf ( <NUM_LIT> , <NUM_LIT:0L> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT:0L> , <NUM_LIT:0L> ) ) ) <EOL> val a : D3Array < Long > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }

/**
 * Tests the function 'createAlignedNDArray' that creates a three-dimensional array from a list of number lists.
 * The test asserts that:
 * - The output array's size matches the size of the longest list in the input
 * and all lists are filled to match this length.
 * - The lists shorter than the longest one are filled with the specified filling value.
 */


@ Test <EOL> fun createZeroFilledFloatArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < Float > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT> } } <EOL> }

/**
 * This method checks if a float array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createFloatArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < Float > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT> } } <EOL> }

/**
 * Creates a float array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromFloatList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) ) <EOL> val a : D3Array < Float > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of float lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromFloatSet ( )

{ <EOL> val set = setOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < Float > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of floats
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveFloatArray ( )

{ <EOL> val array = floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getFloatArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive FloatArray
 * and checks if the array's FloatArray representation matches the input FloatArray.
 */


@ Test <EOL> fun createFloat3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Float > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { it + <NUM_LIT> } <EOL> val expected = floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getFloatArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's FloatArray representation matches the expected output.
 */


@ Test <EOL> fun createFloat3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices < Float > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k . toFloat ( ) } <EOL> val expected = floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getFloatArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's FloatArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedFloat3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , ) ) <EOL> val expected = listOf ( listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) ) <EOL> val a : D3Array < Float > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }


@ Test <EOL> fun createZeroFilledDoubleArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < Double > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:0.0> } } <EOL> }

/**
 * This method checks if a double array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createDoubleArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < Double > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == <NUM_LIT:1.0> } } <EOL> }

/**
 * Creates a double array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromDoubleList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1.0> , <NUM_LIT:3.0> ) , listOf ( <NUM_LIT> , <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT> , <NUM_LIT:2.0> ) ) ) <EOL> val a : D3Array < Double > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of double lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromDoubleSet ( )

{ <EOL> val set = setOf ( <NUM_LIT:1.0> , <NUM_LIT:3.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT:1.0> ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < Double > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of doubles
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveDoubleArray ( )

{ <EOL> val array = doubleArrayOf ( <NUM_LIT:1.0> , <NUM_LIT:3.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2.0> , <NUM_LIT> , <NUM_LIT:3.0> , <NUM_LIT> , <NUM_LIT:3.0> , <NUM_LIT> , <NUM_LIT:1.0> ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getDoubleArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive DoubleArray
 * and checks if the array's DoubleArray representation matches the input DoubleArray.
 */


@ Test <EOL> fun createDouble3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < Double > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { it + <NUM_LIT:3.0> } <EOL> val expected = doubleArrayOf ( <NUM_LIT:3.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getDoubleArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's DoubleArray representation matches the expected output.
 */


@ Test <EOL> fun createDouble3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices < Double > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k . toDouble ( ) } <EOL> val expected = doubleArrayOf ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:3.0> ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getDoubleArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's DoubleArray representation matches the expected output.
 */


@ OptIn ( ExperimentalMultikApi :: class ) <EOL> @ Test <EOL> fun createAlignedDouble3DArray ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1.0> , <NUM_LIT:3.0> ) , listOf ( <NUM_LIT> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , ) ) <EOL> val expected = listOf ( listOf ( listOf ( <NUM_LIT:1.0> , <NUM_LIT:3.0> ) , listOf ( <NUM_LIT> , <NUM_LIT:0.0> ) ) , listOf ( listOf ( <NUM_LIT> , <NUM_LIT> ) , listOf ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) ) ) <EOL> val a : D3Array < Double > = mk . createAlignedNDArray ( list , filling = <NUM_LIT:0.0> ) <EOL> assertEquals ( expected , a . toListD3 ( ) ) <EOL> }


@ Test <EOL> fun createZeroFilledComplexFloatArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < ComplexFloat > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == ComplexFloat . zero } } <EOL> }

/**
 * This method checks if a ComplexFloat array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createComplexFloatArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < ComplexFloat > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == ComplexFloat . one } } <EOL> }

/**
 * Creates a ComplexFloat array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromComplexFloatList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) , listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) ) , listOf ( listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) , listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) ) ) <EOL> val a : D3Array < ComplexFloat > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of complex float lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromComplexFloatSet ( )

{ <EOL> val set = setOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , - <NUM_LIT> + <NUM_LIT> . i , - <NUM_LIT> + <NUM_LIT> . i ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < ComplexFloat > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of complex floats
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveComplexFloatArray ( )

{ <EOL> val array = complexFloatArrayOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getComplexFloatArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive ComplexFloatArray
 * and checks if the array's ComplexFloatArray representation matches the input ComplexFloatArray.
 */


@ Test <EOL> fun createComplexFloat3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < ComplexFloat > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { ComplexFloat ( it + <NUM_LIT> , round ( ( it - <NUM_LIT> ) * <NUM_LIT> ) / <NUM_LIT> ) } <EOL> val expected = complexFloatArrayOf ( <NUM_LIT> - <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getComplexFloatArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's ComplexFloatArray representation matches the expected output.
 */


@ Test <EOL> fun createComplexFloat3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices < ComplexFloat > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k + ComplexFloat ( <NUM_LIT:7> ) } <EOL> val expected = complexFloatArrayOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getComplexFloatArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's ComplexFloatArray representation matches the expected output.
 */


@ Test <EOL> fun createZeroFilledComplexDoubleArray ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . zeros < ComplexDouble > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == ComplexDouble . zero } } <EOL> }

/**
 * This method checks if a ComplexDouble array of a given size is correctly created with all elements set to zero.
 */


@ Test <EOL> fun createComplexDoubleArrayFilledWithOnes ( )

{ <EOL> val dim1 = <NUM_LIT:5> <EOL> val dim2 = <NUM_LIT:7> <EOL> val dim3 = <NUM_LIT:3> <EOL> val a = mk . ones < ComplexDouble > ( dim1 , dim2 , dim3 ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . size ) <EOL> assertEquals ( dim1 * dim2 * dim3 , a . data . size ) <EOL> assertTrue { a . all { it == ComplexDouble . one } } <EOL> }

/**
 * Creates a ComplexDouble array filled with ones of a given size and checks if all elements are set to one.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromComplexDoubleList ( )

{ <EOL> val list = listOf ( listOf ( listOf ( <NUM_LIT:1.0> + <NUM_LIT> . i , <NUM_LIT:3.0> + <NUM_LIT> . i ) , listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:8> + <NUM_LIT> . i ) ) , listOf ( listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) , listOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:2.0> + <NUM_LIT> . i ) ) ) <EOL> val a : D3Array < ComplexDouble > = mk . ndarray ( list ) <EOL> assertEquals ( list , a . toListD3 ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a list of byte lists
 * and checks if the array's list representation matches the input list.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromComplexDoubleSet ( )

{ <EOL> val set = setOf ( <NUM_LIT:1.0> + <NUM_LIT> . i , <NUM_LIT:3.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:2.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , - <NUM_LIT> + <NUM_LIT> . i , - <NUM_LIT:1.0> + <NUM_LIT> . i ) <EOL> val shape = intArrayOf ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> val a : D3Array < ComplexDouble > = mk . ndarray ( set , shape = shape ) <EOL> assertEquals ( set . size , a . size ) <EOL> assertEquals ( set , a . toSet ( ) ) <EOL> }

/**
 * Creates a three-dimensional array from a set of complex doubles
 * and checks if the array's set representation matches the input set.
 */


@ Test <EOL> fun createThreeDimensionalArrayFromPrimitiveComplexDoubleArray ( )

{ <EOL> val array = complexDoubleArrayOf ( <NUM_LIT:1.0> + <NUM_LIT> . i , <NUM_LIT:3.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:2.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:3.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:3.0> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT:1.0> + <NUM_LIT> . i ) <EOL> val a = mk . ndarray ( array , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assertEquals ( array . size , a . size ) <EOL> a . data . getComplexDoubleArray ( ) shouldBe array <EOL> }

/**
 * Creates a three-dimensional array from a primitive ComplexDoubleArray
 * and checks if the array's ComplexDoubleArray representation matches the input ComplexDoubleArray.
 */


@ Test <EOL> fun createComplexDouble3DArrayWithInitializationFunction ( )

{ <EOL> val a = mk . d3array < ComplexDouble > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { ComplexDouble ( it + <NUM_LIT> , round ( ( it - <NUM_LIT> ) * <NUM_LIT> ) / <NUM_LIT> ) } <EOL> val expected = complexDoubleArrayOf ( <NUM_LIT> - <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getComplexDoubleArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function
 * and checks if the array's ComplexDoubleArray representation matches the expected output.
 */


@ Test <EOL> fun createComplexDouble3DArrayWithInitAndIndices ( )

{ <EOL> val a = mk . d3arrayIndices < ComplexDouble > ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) { i , j , k -> i * j + k + ComplexDouble ( <NUM_LIT:7> ) } <EOL> val expected = complexDoubleArrayOf ( <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i , <NUM_LIT> + <NUM_LIT> . i ) <EOL> assertEquals ( expected . size , a . size ) <EOL> a . data . getComplexDoubleArray ( ) shouldBe expected <EOL> }

/**
 * Creates a three-dimensional array with a given size using an initialization function and indices.
 * Checks if the array's ComplexDoubleArray representation matches the expected output.
 */


private fun compressDirectoryToZip ( snapshotFile : File , outputPath : File )

{ <EOL> snapshotFile . parentFile . mkdirs ( ) <EOL> snapshotFile . createNewFile ( ) <EOL> ZipOutputStream ( snapshotFile . outputStream ( ) . buffered ( ) ) . use { zip -> <EOL> zip . setLevel ( Deflater . NO_COMPRESSION ) <EOL> outputPath <EOL> . walkTopDown ( ) <EOL> . filter { file -> ! file . isDirectory || file . isEmptyDirectory } <EOL> . forEach { file -> <EOL> val suffix = if ( file . isDirectory ) "<STR_LIT:/>" else "<STR_LIT>" <EOL> val entry = ZipEntry ( file . relativeTo ( outputPath ) . invariantSeparatorsPath + suffix ) <EOL> zip . putNextEntry ( entry ) <EOL> if ( ! file . isDirectory ) { <EOL> file . inputStream ( ) . buffered ( ) . use { it . copyTo ( zip ) } <EOL> } <EOL> zip . closeEntry ( ) <EOL> } <EOL> zip . flush ( ) <EOL> } <EOL> }

/**
 * Kotlin's compilation in a "fat" project may contain a lot of small files that is slow to copy
 * So we speeding it up by archiving them into single zip file without compression. Such approach reduces snapshotting
 * time up to half ot the time needed to copy similar files.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun Collection < UByte > . toUByteArray ( ) : UByteArray

{ <EOL> val result = UByteArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of UByte containing all of the elements of this collection.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun Collection < UInt > . toUIntArray ( ) : UIntArray

{ <EOL> val result = UIntArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of UInt containing all of the elements of this collection.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun Collection < ULong > . toULongArray ( ) : ULongArray

{ <EOL> val result = ULongArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of ULong containing all of the elements of this collection.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun Collection < UShort > . toUShortArray ( ) : UShortArray

{ <EOL> val result = UShortArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of UShort containing all of the elements of this collection.
 */


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> public fun Iterable < UInt > . sum ( ) : UInt

{ <EOL> var sum : UInt = <NUM_LIT> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }

/**
 * Returns the sum of all elements in the collection.
 */


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> public fun Iterable < ULong > . sum ( ) : ULong

{ <EOL> var sum : ULong = <NUM_LIT> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> public fun Iterable < UByte > . sum ( ) : UInt


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> public fun Iterable < UShort > . sum ( ) : UInt


fun dispose ( )

/**
 * Disposes all native resources owned by this class. This function must be invoked
 * exactly once as the last operation on the corresponding class.
 */


fun getTopLevelCallableSymbols ( callableId : CallableId , callableFiles : Collection < KtFile > ? ) : List < FirCallableSymbol < * > >

{ <EOL> if ( ! allowKotlinPackage && callableId . packageName . isKotlinPackage ( ) ) return emptyList ( ) <EOL> return callablesByCallableId . getValue ( callableId , callableFiles ) <EOL> }

/**
 * [callableFiles] are the [KtFile]s which contain callables of the given package and name. If already known, they can be provided to
 * avoid index accesses.
 */


private fun KtAnalysisSession . getDokkaScopeFrom ( namedClassOrObjectSymbol : KtNamedClassOrObjectSymbol , dri : DRI , includeStaticScope : Boolean = true ) : DokkaScope

{ <EOL> val scope = if ( includeStaticScope ) namedClassOrObjectSymbol . getCombinedMemberScope ( ) else namedClassOrObjectSymbol . getMemberScope ( ) <EOL> val constructors = scope . getConstructors ( ) . map { visitConstructorSymbol ( it ) } . toList ( ) <EOL> val callables = scope . getCallableSymbols ( ) . toList ( ) <EOL> val classifiers = if ( includeStaticScope ) namedClassOrObjectSymbol . getStaticMemberScope ( ) . getClassifierSymbols ( ) else emptySequence ( ) <EOL> val syntheticJavaProperties = <EOL> namedClassOrObjectSymbol . buildSelfClassType ( ) . getSyntheticJavaPropertiesScope ( ) ? . getCallableSignatures ( ) <EOL> ? . map { it . symbol } <EOL> ? . filterIsInstance < KtSyntheticJavaPropertySymbol > ( ) ? : emptySequence ( ) <EOL> fun List < KtJavaFieldSymbol > . filterOutSyntheticJavaPropBackingField ( ) = <EOL> filterNot { javaField -> syntheticJavaProperties . any { it . hasBackingField && javaField . name == it . name } } <EOL> val javaFields = callables . filterIsInstance < KtJavaFieldSymbol > ( ) <EOL> . filterOutSyntheticJavaPropBackingField ( ) <EOL> fun List < KtFunctionSymbol > . filterOutSyntheticJavaPropAccessors ( ) = filterNot { fn -> <EOL> if ( fn . origin == KtSymbolOrigin . JAVA && fn . callableIdIfNonLocal != null ) <EOL> syntheticJavaProperties . any { fn . callableIdIfNonLocal == it . javaGetterSymbol . callableIdIfNonLocal || fn . callableIdIfNonLocal == it . javaSetterSymbol ? . callableIdIfNonLocal } <EOL> else false <EOL> } <EOL> val functions = callables . filterIsInstance < KtFunctionSymbol > ( ) <EOL> . filterOutSyntheticJavaPropAccessors ( ) . map { visitFunctionSymbol ( it , dri ) } <EOL> val properties = callables . filterIsInstance < KtPropertySymbol > ( ) . map { visitPropertySymbol ( it , dri ) } + <EOL> syntheticJavaProperties . map { visitPropertySymbol ( it , dri ) } + <EOL> javaFields . map { visitJavaFieldSymbol ( it , dri ) } <EOL> fun Sequence < KtNamedClassOrObjectSymbol > . filterOutCompanion ( ) = <EOL> filterNot { <EOL> it . classKind == KtClassKind . COMPANION_OBJECT <EOL> } <EOL> val classlikes = classifiers . filterIsInstance < KtNamedClassOrObjectSymbol > ( ) <EOL> . filterOutCompanion ( ) <EOL> . map { visitNamedClassOrObjectSymbol ( it , dri ) } <EOL> return DokkaScope ( constructors = constructors , functions = functions , properties = properties , classlikesWithoutCompanion = classlikes . toList ( ) ) <EOL> }

/**
 * @return a scope [DokkaScope] consisting of:
 * - primary and secondary constructors
 * - member functions, including inherited ones
 * - member properties, including inherited ones and synthetic java properties
 * - classlikes (classes and objects **except a companion**) that are explicitly declared in [namedClassOrObjectSymbol]
 * only if [includeStaticScope] is enabled
 *
 * @param includeStaticScope a flag to add static members, e.g. `valueOf`, `values` and `entries` members for Enum.
 * See [org.jetbrains.kotlin.analysis.api.components.KtScopeProvider.getStaticDeclaredMemberScope] for what a static scope is.
 */


private fun DRI . getInheritedFromDRI ( dri : DRI ) : DRI ?

{ <EOL> return this . copy ( callable = null ) <EOL> . takeIf { dri . classNames != this . classNames || dri . packageName != this . packageName } <EOL> }

/**
 * `createDRI` returns the DRI of the exact element and potential DRI of an element that is overriding it
 * (It can be also FAKE_OVERRIDE which is in fact just inheritance of the symbol)
 *
 * Looking at what PSIs do, they give the DRI of the element within the classnames where it is actually
 * declared and inheritedFrom as the same DRI but truncated callable part.
 * Therefore, we set callable to null and take the DRI only if it is indeed coming from different class.
 */


@ PublishedApi <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun checkBounds ( value : Boolean , index : Int , axis : Int , size : Int )

{ <EOL> if ( ! value ) { <EOL> throw IndexOutOfBoundsException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Checks if the given index is within the bounds of the given axis and the size of the shape.
 *
 * @param value the boolean value representing whether the index is within bounds
 * @param index the integer value representing the index to check
 * @param axis the integer value representing the axis dimension to check against
 * @param size the integer value representing the size of the shape on the given axis dimension
 *
 * @throws IndexOutOfBoundsException when the index is out of bounds for the given axis and size
 */


@ PublishedApi <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requireDimension ( dim : Dimension , shapeSize : Int )

{ <EOL> require ( dim . d == shapeSize || ( dim . d > <NUM_LIT:4> && shapeSize > <NUM_LIT:4> ) ) <EOL> { "<STR_LIT>" } <EOL> }

/**
 * Checks if the given dimension matches the provided shape size, or if the dimension is greater than 4
 * and shape size is greater than 4.
 *
 * @param dim the input dimension object to check.
 * @param shapeSize the size of the shape to compare with.
 * @throws IllegalArgumentException if the dimension doesn't match the size of the shape.
 */


@ PublishedApi <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requireShapeEmpty ( shape : IntArray )

{ <EOL> require ( shape . isNotEmpty ( ) ) { "<STR_LIT>" } <EOL> }

/**
 * Check if the given shape is empty.
 *
 * @param shape An array of integers representing the shape to be checked.
 * @throws IllegalArgumentException if the given shape is empty.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requireElementsWithShape ( elementSize : Int , shapeSize : Int )

{ <EOL> require ( elementSize == shapeSize ) { "<STR_LIT>" } <EOL> }

/**
 * Checks if the number of elements matches the specified shape.
 *
 * @param elementSize the number of elements in the element list
 * @param shapeSize the size of the given shape
 * @throws IllegalArgumentException if the number of elements doesn't match the shape
 */


@ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requireArraySizes ( rightSize : Int , otherSize : Int )

{ <EOL> require ( rightSize == otherSize ) { "<STR_LIT>" } <EOL> }

/**
 * Asserts that two array sizes are equal.
 *
 * @param rightSize the size of the right operand array
 * @param otherSize the size of the left operand array
 *
 * @throws IllegalArgumentException if the two sizes don't match
 */


@ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requireEqualShape ( left : IntArray , right : IntArray )

{ <EOL> require ( left . contentEquals ( right ) ) { "<STR_LIT>" } <EOL> }

/**
 * Checks if two given integer arrays have equal shape.
 *
 * @param left the first integer array to compare
 * @param right the second integer array to compare
 * @throws IllegalArgumentException if the shapes of the arrays do not match
 */


@ Suppress ( "<STR_LIT>" ) <EOL> internal inline fun requirePositiveShape ( dim : Int )

{ <EOL> require ( dim > <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> }

/**
 * Checks if the given dimension is positive or not. Throws an IllegalArgumentException if the shape is not positive.
 *
 * @param dim an integer representing the dimension of the shape.
 * @throws IllegalArgumentException if the shape dimension is not positive.
 */


internal fun computeStrides ( shape : IntArray ) : IntArray

= shape . copyOf ( ) . apply { <EOL> this [ this . lastIndex ] = <NUM_LIT:1> <EOL> for ( i in this . lastIndex - <NUM_LIT:1> downTo <NUM_LIT:0> ) { <EOL> this [ i ] = this [ i + <NUM_LIT:1> ] * shape [ i + <NUM_LIT:1> ] <EOL> } <EOL> }

/**
 * Computes the strides for a multidimensional array given the shape.
 *
 * @param shape an array representing the shape of the multidimensional array
 * @return an integer array containing the strides of the multidimensional array
 */


internal fun MultiArray < * , * > . actualAxis ( axis : Int ) : Int

{ <EOL> return if ( axis < <NUM_LIT:0> ) dim . d + axis else axis <EOL> }

/**
 * Returns the actual axis index by converting a negative index to positive index relative to the array dimensions
 *
 * @param axis the index of the axis to retrieve
 * @return the actual axis index
 */


@ PublishedApi <EOL> internal fun IntArray . remove ( pos : Int ) : IntArray

= when ( pos ) { <EOL> <NUM_LIT:0> -> sliceArray ( <NUM_LIT:1> .. lastIndex ) <EOL> lastIndex -> sliceArray ( <NUM_LIT:0> until lastIndex ) <EOL> else -> sliceArray ( <NUM_LIT:0> until pos ) + sliceArray ( pos + <NUM_LIT:1> .. lastIndex ) <EOL> }

/**
 * Removes the element at the specified position in this IntArray.
 *
 * @param pos the position of the element to be removed
 * @return the new IntArray with the element removed
 */


internal fun IntArray . removeAll ( indices : List < Int > ) : IntArray

= when { <EOL> indices . isEmpty ( ) -> this <EOL> indices . size == <NUM_LIT:1> -> remove ( indices . first ( ) ) <EOL> else -> this . filterIndexed { index , _ -> index !in indices } . toIntArray ( ) <EOL> }

/**
 * Removes elements from the array with indices specified in the given list.
 *
 * @param indices the list of element indices to be removed from the array.
 * @return the new array with requested elements removed, or the original array if the list is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public fun isInstance ( value : Any ? ) : Boolean

/**
 * Returns `true` if [value] is an instance of this class on a given platform.
 */


fun isAccessToUnstableLocalVariable ( expression : FirElement , targetType : ConeKotlinType ? ) : Boolean

= <EOL> context . variableAssignmentAnalyzer . isAccessToUnstableLocalVariable ( expression , targetType , components . session )

/**
 * When variable access resolution encounters a variable access which has smartcast information, assignments associated with that
 * variable are checked to determine variable stability, and therefore smartcast stability. These assignments are tracked by
 * [FirLocalVariableAssignmentAnalyzer], which knows how each assignment may limit variable stability, like assignments within or after
 * a non-in-place lambda body. So for a given lexical scope (function body, lambda body, and even local class init) and a given
 * variable, [FirLocalVariableAssignmentAnalyzer] knows all associated assignments (past and/or future) which could limit stability.
 *
 * When a [targetType] is provided, all assignments are checked for the specified variable access expression:
 * 1. If there are no assignments, the variable is always considered **stable**.
 * 2. If there is an unresolved assignment type, the variable is considered **unstable**.
 * 3. If any resolved assignment type is not a subtype of the [targetType], the variable is considered **unstable**.
 * 4. If none of the previous conditions are true, the variable is considered **stable**.
 *
 * When a [targetType] is **not** provided, **any** assignments cause the variable to be considered **unstable**.
 *
 * @param expression The variable access expression.
 * @param targetType Smartcast target type (optional: see function description).
 *
 * @see [getTypeUsingSmartcastInfo]
 * @see [FirLocalVariableAssignmentAnalyzer.isAccessToUnstableLocalVariable]
 * @see [FirLocalVariableAssignmentAnalyzer.isStableType]
 */


open fun getTypeUsingSmartcastInfo ( expression : FirExpression ) : Pair < PropertyStability , MutableList < ConeKotlinType > > ?

{ <EOL> val flow = currentSmartCastPosition ? : return null <EOL> val variable = getRealVariableWithoutUnwrappingAlias ( flow , expression ) ? : return null <EOL> val types = flow . getTypeStatement ( variable ) ? . exactType ? . ifEmpty { null } ? : return null <EOL> return variable . stability to types . toMutableList ( ) <EOL> }

/**
 * Retrieve smartcast type information [FirDataFlowAnalyzer] may have for the specified variable access expression. Type information
 * is **stateful** and changes as the FIR tree is navigated by [FirDataFlowAnalyzer].
 *
 * @param expression The variable access expression.
 */


private fun isSmartcastPrimitive ( classId : ClassId ? ) : Boolean

{ <EOL> return when ( classId ) { <EOL> StandardClassIds . String , <EOL> -> true <EOL> else -> false <EOL> } <EOL> }

/**
 * Determines if type smart-casting to the specified [ClassId] can be performed when values are
 * compared via equality. Because this is determined using the ClassId, only standard built-in
 * types are considered.
 */


public fun horizontal ( name : String , yAxis : Number ) : MarkLine

= MarkLine ( nameML = name , xAxis = yAxis . toDouble ( ) )

/**
 * Returns a horizontal line along a point on the y-axis.
 */


public fun vertical ( name : String , xAxis : Number ) : MarkLine

= MarkLine ( nameML = name , xAxis = xAxis . toDouble ( ) )

/**
 * Returns a horizontal line along a point on the x-axis.
 */


@ ExperimentalKotlinGradlePluginApi <EOL> fun KotlinHierarchyTemplate ( describe : KotlinHierarchyBuilder . Root . ( ) -> Unit , ) : KotlinHierarchyTemplate

{ <EOL> return KotlinHierarchyTemplateImpl ( describe ) <EOL> }

/**
 * @suppress TODO: KT-58858 add documentation
 */


@ ExperimentalKotlinGradlePluginApi <EOL> fun KotlinHierarchyTemplate . extend ( describe : KotlinHierarchyBuilder . Root . ( ) -> Unit ) : KotlinHierarchyTemplate

{ <EOL> return KotlinHierarchyTemplate { <EOL> this@extend . impl . layout ( this ) <EOL> describe ( ) <EOL> } <EOL> }


@ InternalKotlinGradlePluginApi <EOL> @ OptIn ( ExperimentalKotlinGradlePluginApi :: class ) <EOL> fun KotlinHierarchyBuilder . Root . applyHierarchyTemplate ( template : KotlinHierarchyTemplate )

{ <EOL> template . impl . layout ( this ) <EOL> }


@ Benchmark <EOL> fun addAndRemoveAll_All ( ) : Boolean

{ <EOL> val builder = persistentListBuilderAddIndexes ( ) <EOL> val elementsToRemove = List ( size ) { it } <EOL> return builder . removeAll ( elementsToRemove ) <EOL> }

/**
 * Adds [size] elements to an empty persistent list builder
 * and then removes all of them using `removeAll(elements)` operation.
 */


@ Benchmark <EOL> fun addAndRemoveAll_RandomHalf ( ) : Boolean

{ <EOL> val builder = persistentListBuilderAddIndexes ( ) <EOL> val elementsToRemove = randomIndexes ( size / <NUM_LIT:2> ) <EOL> return builder . removeAll ( elementsToRemove ) <EOL> }

/**
 * Adds [size] elements to an empty persistent list builder
 * and then removes half of them using `removeAll(elements)` operation.
 */


@ Benchmark <EOL> fun addAndRemoveAll_RandomTen ( ) : Boolean

{ <EOL> val builder = persistentListBuilderAddIndexes ( ) <EOL> val elementsToRemove = randomIndexes ( <NUM_LIT:10> ) <EOL> return builder . removeAll ( elementsToRemove ) <EOL> }

/**
 * Adds [size] elements to an empty persistent list builder
 * and then removes 10 of them using `removeAll(elements)` operation.
 */


@ Benchmark <EOL> fun addAndRemoveAll_Tail ( ) : Boolean

{ <EOL> val builder = persistentListBuilderAddIndexes ( ) <EOL> val elementsToRemove = List ( tailSize ( ) ) { size - <NUM_LIT:1> - it } <EOL> return builder . removeAll ( elementsToRemove ) <EOL> }

/**
 * Adds [size] elements to an empty persistent list builder
 * and then removes last [tailSize] of them using `removeAll(elements)` operation.
 */


@ Benchmark <EOL> fun addAndRemoveAll_NonExisting ( ) : Boolean

{ <EOL> val builder = persistentListBuilderAddIndexes ( ) <EOL> val elementsToRemove = randomIndexes ( <NUM_LIT:10> ) . map { size + it } <EOL> return builder . removeAll ( elementsToRemove ) <EOL> }

/**
 * Adds [size] elements to an empty persistent list builder
 * and then removes 10 non-existing elements using `removeAll(elements)` operation.
 */


fun removeUnusedLocalFunctionDeclarations ( root : JsNode )

{ <EOL> val removable = <EOL> with ( UnusedInstanceCollector ( ) ) { <EOL> accept ( root ) <EOL> removableDeclarations <EOL> } <EOL> NodeRemover ( JsStatement :: class . java ) { <EOL> it in removable <EOL> } . accept ( root ) <EOL> }

/**
 * Removes unused local function declarations like:
 * var inc = _.foo.f$inc(a)
 *
 * Declaration can become unused, if inlining happened.
 */


inline fun < T , R > Iterable < T > . flatMapToNullableSet ( transform : ( T ) -> Iterable < R > ? ) : Set < R > ?

= <EOL> flatMapTo ( mutableSetOf ( ) ) { transform ( it ) ? : return null } . ifEmpty { emptySet ( ) }

/**
 * Works almost as regular flatMap, but returns a set and returns null if any lambda call returned null
 */


inline fun < T , R > Collection < T > . mapToSetOrEmpty ( transform : ( T ) -> R ) : Set < R >

= <EOL> if ( isNotEmpty ( ) ) mapTo ( mutableSetOf ( ) , transform ) else emptySet ( )

/**
 * Maps all elements of this non-empty collection with the given [transform] function to a new mutable set, or returns [emptySet] if this
 * collection is empty.
 *
 * [mapToSetOrEmpty] should be preferred over `collection.mapTo(mutableSetOf()) { ... }` when `collection` may be empty and the resulting
 * set may be cached, because [mapToSetOrEmpty] saves memory by avoiding the creation of an empty mutable set.
 */


{ <EOL> }


public abstract fun findInternalFilesForFacade ( facadeFqName : FqName ) : Collection < KtFile >

/**
 * Currently we want only classes from libraries ([org.jetbrains.kotlin.analysis.decompiler.psi.file.KtClsFile])
 */


public open fun computePackageNames ( ) : Set < String > ?

= null

/**
 * Calculates the set of package names which can be provided by this declaration provider.
 *
 * The set may contain false positives. `null` may be returned if the package set is too expensive or impossible to compute.
 *
 * [computePackageNames] is used as the default implementation for [computePackageNamesWithTopLevelClassifiers] and
 * [computePackageNamesWithTopLevelCallables] if either returns `null`. It depends on the declaration provider whether it's worth
 * computing separate package sets for classifiers and callables, or just one set containing all package names.
 */


public open fun computePackageNamesWithTopLevelClassifiers ( ) : Set < String > ?

= computePackageNames ( )

/**
 * Calculates the set of package names which contain classifiers and can be provided by this declaration provider.
 *
 * The set may contain false positives. `null` may be returned if the package set is too expensive or impossible to compute.
 */


public open fun computePackageNamesWithTopLevelCallables ( ) : Set < String > ?

= computePackageNames ( )

/**
 * Calculates the set of package names which contain callables and can be provided by this declaration provider.
 *
 * The set may contain false positives. `null` may be returned if the package set is too expensive or impossible to compute.
 */


public fun Project . createDeclarationProvider ( scope : GlobalSearchScope , contextualModule : KtModule ? ) : KotlinDeclarationProvider

= <EOL> KotlinDeclarationProviderFactory . getInstance ( this ) . createDeclarationProvider ( scope , contextualModule )

/**
 * Creates a [KotlinDeclarationProvider] providing symbols within the given [scope].
 *
 * The [contextualModule] is the module which contains the symbols to be provided, if applicable. The declaration provider may use the
 * contextual module to provide declarations differently, such as providing alternative declarations for an outsider module. Some
 * functionality such as package set computation may also depend on the contextual module, as the declaration provider may require
 * additional information not available in the [scope].
 */


override fun getExternalAnnotationsRoots ( libraryFile : VirtualFile ) : List < VirtualFile >

= externalAnnotationsRoots

/**
 * We simply returns [externalAnnotationsRoots] because there is all our declared 'annotations.xml' files
 *
 * @param libraryFile is a file for which we want to find the corresponding external annotations file if it exists
 */


fun KotlinPlatform . getRuntimeType ( name : String , nullable : Boolean = false ) : StubType

{ <EOL> val classifier = Classifier . topLevel ( cinteropPackage , name ) <EOL> PredefinedTypesHandler . tryExpandPlatformDependentTypealias ( classifier , this , nullable ) ? . let { return it } <EOL> return ClassifierStubType ( classifier , nullable = nullable ) <EOL> }

/**
 * @return type from kotlinx.cinterop package
 */


private fun getVarOfTypeFor ( primitiveType : KotlinClassifierType , nullable : Boolean ) : ClassifierStubType

{ <EOL> val typeVarOf = "<STR_LIT>" <EOL> val classifier = Classifier . topLevel ( cInteropPackage , typeVarOf ) <EOL> return ClassifierStubType ( classifier , listOf ( TypeArgumentStub ( primitiveType . toStubIrType ( ) ) ) , nullable = nullable ) <EOL> }

/**
 * @param primitiveType primitive type from kotlin package.
 * @return kotlinx.cinterop.[primitiveType]VarOf<[primitiveType]>
 */


private fun expandPrimitiveVarType ( primitiveVarClassifier : Classifier , nullable : Boolean ) : AbbreviatedType

{ <EOL> val primitiveType = primitiveVarClassifierToPrimitiveType . getValue ( primitiveVarClassifier ) <EOL> val underlyingType = getVarOfTypeFor ( primitiveType , nullable ) <EOL> return AbbreviatedType ( underlyingType , primitiveVarClassifier , listOf ( ) , nullable ) <EOL> }

/**
 * @param primitiveVarType one of kotlinx.cinterop.{primitive}Var types.
 * @return typealias in terms of StubIR types.
 */


fun tryExpandPredefinedTypealias ( classifier : Classifier , nullable : Boolean , typeArguments : List < TypeArgument > ) : AbbreviatedType ?

= <EOL> when ( classifier ) { <EOL> in primitiveVarClassifierToPrimitiveType . keys -> expandPrimitiveVarType ( classifier , nullable ) <EOL> KotlinTypes . cOpaquePointer . classifier -> expandCOpaquePointer ( nullable ) <EOL> KotlinTypes . cOpaquePointerVar . classifier -> expandCOpaquePointerVar ( nullable ) <EOL> KotlinTypes . cPointerVar -> expandCPointerVar ( typeArguments , nullable ) <EOL> KotlinTypes . objCObjectMeta -> expandObjCObjectMeta ( typeArguments , nullable ) <EOL> KotlinTypes . cArrayPointer -> expandCArrayPointer ( typeArguments , nullable ) <EOL> KotlinTypes . objCBlockVar -> expandObjCBlockVar ( typeArguments , nullable ) <EOL> else -> null <EOL> }

/**
 * @return [ClassifierStubType] if [classifier] is a typealias from [kotlinx.cinterop] package.
 */


fun tryExpandPlatformDependentTypealias ( classifier : Classifier , platform : KotlinPlatform , nullable : Boolean ) : StubType ?

= <EOL> when ( classifier ) { <EOL> nativePtrClassifier -> expandNativePtr ( platform , nullable ) <EOL> else -> null <EOL> }

/**
 * Variant of [tryExpandPredefinedTypealias] with [platform]-dependent result.
 */


fun isAbstractOnJvmIgnoringActualModality ( descriptor : FunctionDescriptor , jvmDefaultMode : JvmDefaultMode ) : Boolean

{ <EOL> if ( ! DescriptorUtils . isInterface ( descriptor . containingDeclaration ) ) return false <EOL> return ! descriptor . isJvmDefaultOrPlatformDependent ( jvmDefaultMode ) <EOL> }

/**
 * @return return true for interface method not annotated with @JvmDefault or @PlatformDependent
 */


{ <EOL> val ( train , _ ) = mnist ( ) <EOL> val inferenceModel = TensorFlowInferenceModel . load ( File ( PATH_TO_MODEL ) , loadOptimizerState = true ) <EOL> inferenceModel . use { <EOL> var accuracy = <NUM_LIT:0.0> <EOL> val amountOfTestSet = <NUM_LIT> <EOL> for ( imageId in <NUM_LIT:0> .. amountOfTestSet ) { <EOL> val prediction = it . predict ( train . getX ( imageId ) ) <EOL> if ( prediction == train . getY ( imageId ) . toInt ( ) ) <EOL> accuracy += ( <NUM_LIT:1.0> / amountOfTestSet ) <EOL> } <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Inference model is used here, separately from model training code to illustrate the ability to load model graph and weights to start prediction process.
 *
 * NOTE: The example requires the saved model in the appropriate directory (run [lenetOnMnistDatasetExportImportToTxt] firstly).
 */


private fun getMangledNameFor ( declarationName : String , parent : IrDeclarationParent ) : Name

{ <EOL> val prefix = parent . fqNameForIrSerialization <EOL> return "<STR_LIT>" . synthesizedName <EOL> }

/**
 * Generate name for declaration that will be a part of internal ABI.
 */


private inline fun < R : Any > dumpCoroutinesInfoImpl ( crossinline create : ( CoroutineOwner < * > , CoroutineContext ) -> R ) : List < R >

{ <EOL> check ( isInstalled ) { "<STR_LIT>" } <EOL> return capturedCoroutines <EOL> . asSequence ( ) <EOL> . sortedBy { it . info . sequenceNumber } <EOL> . mapNotNull { owner -> <EOL> if ( owner . isFinished ( ) ) null <EOL> else owner . info . context ? . let { context -> create ( owner , context ) } <EOL> } . toList ( ) <EOL> }

/**
 * Private method that dumps coroutines so that different public-facing method can use
 * to produce different result types.
 */


private fun enhanceStackTraceWithThreadDumpImpl ( state : String , thread : Thread ? , coroutineTrace : List < StackTraceElement > ) : List < StackTraceElement >

{ <EOL> if ( state != RUNNING || thread == null ) return coroutineTrace <EOL> val actualTrace = runCatching { thread . stackTrace } . getOrNull ( ) <EOL> ? : return coroutineTrace <EOL> val indexOfResumeWith = actualTrace . indexOfFirst { <EOL> it . className == "<STR_LIT>" && <EOL> it . methodName == "<STR_LIT>" && <EOL> it . fileName == "<STR_LIT>" <EOL> } <EOL> val ( continuationStartFrame , delta ) = findContinuationStartIndex ( indexOfResumeWith , actualTrace , coroutineTrace ) <EOL> if ( continuationStartFrame == - <NUM_LIT:1> ) return coroutineTrace <EOL> val expectedSize = indexOfResumeWith + coroutineTrace . size - continuationStartFrame - <NUM_LIT:1> - delta <EOL> val result = ArrayList < StackTraceElement > ( expectedSize ) <EOL> for ( index in <NUM_LIT:0> until indexOfResumeWith - delta ) { <EOL> result += actualTrace [ index ] <EOL> } <EOL> for ( index in continuationStartFrame + <NUM_LIT:1> until coroutineTrace . size ) { <EOL> result += coroutineTrace [ index ] <EOL> } <EOL> return result <EOL> }

/**
 * Tries to enhance [coroutineTrace] (obtained by call to [DebugCoroutineInfoImpl.lastObservedStackTrace]) with
 * thread dump of [DebugCoroutineInfoImpl.lastObservedThread].
 *
 * Returns [coroutineTrace] if enhancement was unsuccessful or the enhancement result.
 */


private fun findContinuationStartIndex ( indexOfResumeWith : Int , actualTrace : Array < StackTraceElement > , coroutineTrace : List < StackTraceElement > ) : Pair < Int , Int >

{ <EOL> repeat ( <NUM_LIT:3> ) { <EOL> val result = findIndexOfFrame ( indexOfResumeWith - <NUM_LIT:1> - it , actualTrace , coroutineTrace ) <EOL> if ( result != - <NUM_LIT:1> ) return result to it <EOL> } <EOL> return - <NUM_LIT:1> to <NUM_LIT:0> <EOL> }

/**
 * Tries to find the lowest meaningful frame above `resumeWith` in the real stacktrace and
 * its match in a coroutines stacktrace (steps 2-3 in heuristic).
 *
 * This method does more than just matching `realTrace.indexOf(resumeWith) - 1`:
 * If method above `resumeWith` has no line number (thus it is `stateMachine.invokeSuspend`),
 * it's skipped and attempt to match next one is made because state machine could have been missing in the original coroutine stacktrace.
 *
 * Returns index of such frame (or -1) and number of skipped frames (up to 2, for state machine and for access$).
 */


fun getIncrementalProcessorsFromClasspath ( names : Set < String > , classpath : Iterable < File > ) : Map < String , DeclaredProcType >

{ <EOL> val finalValues = mutableMapOf < String , DeclaredProcType > ( ) <EOL> classpath . forEach { entry -> <EOL> val fromEntry = processSingleClasspathEntry ( entry ) <EOL> fromEntry . filter { names . contains ( it . key ) } . forEach { finalValues [ it . key ] = it . value } <EOL> if ( finalValues . size == names . size ) return finalValues <EOL> } <EOL> return finalValues <EOL> }

/** Checks the incremental annotation processor information for the annotation processor classpath. */


internal expect fun withCaughtException ( block : ( ) -> Unit ) : Throwable ?

/**
 * Kotlin/Wasm can't handle exceptions thrown by a JS runtime.
 * This function wraps a block that may potentially throw something and returns an exception if it was caught.
 */


override fun clearValueInfo ( value : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : DataFlowInfo

{ <EOL> val resultNullabilityInfo = hashMapOf < DataFlowValue , Nullability > ( ) <EOL> putNullabilityAndTypeInfo ( resultNullabilityInfo , value , value . immanentNullability , languageVersionSettings ) <EOL> return create ( this , resultNullabilityInfo , EMPTY_TYPE_INFO , value ) <EOL> }

/**
 * Call this function to clear all data flow information about
 * the given data flow value.

 * @param value
 */


fun getLambdaMetafactoryArguments ( reference : IrFunctionReference , samType : IrType , plainLambda : Boolean ) : MetafactoryArgumentsResult

{ <EOL> val samClass = samType . getClass ( ) <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> var semanticsHazard = false <EOL> var abiHazard = false <EOL> var inliningHazard = false <EOL> var shouldBeSerializable = false <EOL> var functionHazard = false <EOL> if ( ! reference . origin . isLambda && ( ! samClass . isFromJava ( ) || isJavaSamConversionWithEqualsHashCode ) ) { <EOL> semanticsHazard = true <EOL> } <EOL> if ( samClass . isInheritedFromSerializable ( ) ) { <EOL> shouldBeSerializable = true <EOL> } <EOL> val samMethod = samClass . getSingleAbstractMethod ( ) <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> if ( samMethod . isSuspend ) { <EOL> abiHazard = true <EOL> } <EOL> if ( samClass . requiresDelegationToDefaultImpls ( ) ) { <EOL> abiHazard = true <EOL> } <EOL> val implFun = reference . symbol . owner <EOL> if ( implFun . typeParameters . any { it . isReified } ) { <EOL> functionHazard = true <EOL> } <EOL> if ( context . getIntrinsic ( implFun . symbol ) != null ) { <EOL> functionHazard = true <EOL> } <EOL> if ( implFun . isInline ) { <EOL> functionHazard = true <EOL> } <EOL> if ( isConstructorRequiringAccessor ( implFun ) ) { <EOL> functionHazard = true <EOL> } <EOL> if ( implFun is IrSimpleFunction ) { <EOL> val baseFun = findSuperDeclaration ( implFun , false , context . config . jvmDefaultMode ) <EOL> val baseFunClass = baseFun . parent as? IrClass <EOL> if ( baseFunClass != null && baseFunClass . visibility == JavaDescriptorVisibilities . PACKAGE_VISIBILITY ) { <EOL> functionHazard = true <EOL> } <EOL> } <EOL> val implFunParent = implFun . parent <EOL> if ( implFunParent is IrClass && implFunParent . origin == IrDeclarationOrigin . JVM_MULTIFILE_CLASS ) { <EOL> functionHazard = true <EOL> } <EOL> if ( reference . origin . isLambda && implFun . annotations . isNotEmpty ( ) ) { <EOL> abiHazard = true <EOL> } <EOL> if ( plainLambda ) { <EOL> var parametersCount = implFun . valueParameters . size <EOL> if ( implFun . extensionReceiverParameter != null ) ++ parametersCount <EOL> if ( parametersCount >= BuiltInFunctionArity . BIG_ARITY ) <EOL> abiHazard = true <EOL> } <EOL> if ( implFun . parents . any { it . isInlineFunction ( ) || it . isCrossinlineLambda ( ) } ) { <EOL> inliningHazard = true <EOL> } <EOL> if ( samType is IrSimpleType ) { <EOL> if ( samType . arguments . any { it is IrStarProjection || it is IrTypeProjection && it . variance != Variance . INVARIANT } ) { <EOL> abiHazard = true <EOL> } <EOL> } <EOL> when { <EOL> semanticsHazard -> return MetafactoryArgumentsResult . Failure . LambdaMetafactorySemanticsHazard <EOL> abiHazard -> return MetafactoryArgumentsResult . Failure . LambdaMetafactoryAbiHazard <EOL> inliningHazard -> return MetafactoryArgumentsResult . Failure . InliningHazard <EOL> functionHazard -> return MetafactoryArgumentsResult . Failure . FunctionHazard <EOL> } <EOL> return getLambdaMetafactoryArgsOrNullInner ( reference , samMethod , samType , implFun , shouldBeSerializable ) <EOL> ? : MetafactoryArgumentsResult . Failure . FunctionHazard <EOL> }

/**
 * @see java.lang.invoke.LambdaMetafactory
 */


@ ParameterizedTest ( name = "<STR_LIT>" ) <EOL> @ ArgumentsSource ( AllSupportedTestedVersionsArgumentsProvider :: class ) <EOL> fun execute ( buildVersions : BuildVersions )

{ <EOL> val result = createGradleRunner ( buildVersions , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . buildRelaxed ( ) <EOL> assertEquals ( TaskOutcome . SUCCESS , assertNotNull ( result . task ( "<STR_LIT>" ) ) . outcome ) <EOL> val outputDir = File ( projectDir , "<STR_LIT>" ) <EOL> assertTrue ( outputDir . isDirectory , "<STR_LIT>" ) <EOL> val result2 = createGradleRunner ( buildVersions , "<STR_LIT:clean>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . buildRelaxed ( ) <EOL> assertEquals ( TaskOutcome . SUCCESS , assertNotNull ( result2 . task ( "<STR_LIT>" ) ) . outcome ) <EOL> val outputDir2 = File ( projectDir , "<STR_LIT>" ) <EOL> assertTrue ( outputDir2 . isDirectory , "<STR_LIT>" ) <EOL> val result3 = createGradleRunner ( buildVersions , "<STR_LIT:clean>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . buildRelaxed ( ) <EOL> assertEquals ( TaskOutcome . SUCCESS , assertNotNull ( result3 . task ( "<STR_LIT>" ) ) . outcome ) <EOL> val outputDirMultiModule = File ( projectDir , "<STR_LIT>" ) <EOL> assertTrue ( outputDirMultiModule . isDirectory , "<STR_LIT>" ) <EOL> val version1_0 = outputDirMultiModule . resolve ( "<STR_LIT>" ) . resolve ( "<STR_LIT:1.0>" ) <EOL> val version1_1 = outputDirMultiModule . resolve ( "<STR_LIT>" ) . resolve ( "<STR_LIT:1.1>" ) <EOL> assertTrue ( version1_0 . isDirectory , "<STR_LIT>" ) <EOL> assertTrue ( version1_1 . isDirectory , "<STR_LIT>" ) <EOL> assertFalse ( version1_0 . resolve ( "<STR_LIT>" ) . exists ( ) , "<STR_LIT>" ) <EOL> assertFalse ( version1_1 . resolve ( "<STR_LIT>" ) . exists ( ) , "<STR_LIT>" ) <EOL> val parsedIndex = Jsoup . parse ( outputDirMultiModule . resolve ( "<STR_LIT>" ) . readText ( ) ) <EOL> val dropdown = parsedIndex . select ( "<STR_LIT>" ) . firstOrNull ( ) <EOL> assertNotNull ( dropdown ) <EOL> val links = dropdown . select ( "<STR_LIT:a>" ) <EOL> assertEquals ( <NUM_LIT:3> , links . count ( ) , "<STR_LIT>" ) <EOL> assertEquals ( listOf ( "<STR_LIT:1.2>" to "<STR_LIT>" , "<STR_LIT:1.1>" to "<STR_LIT>" , "<STR_LIT:1.0>" to "<STR_LIT>" ) , links . map { it . text ( ) to it . attr ( "<STR_LIT>" ) } ) <EOL> }

/**
 * This test runs versioning 3 times to simulate how users might use it in the real word
 *
 * Each version has a separate task that has a different version number from 1.0 to 1.2 and is placed under `buildDir/dokkas/<version>`
 *
 * Output is produced in a standard build directory under `build/dokka/htmlMultiModule`
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public fun Random . asJavaRandom ( ) : java . util . Random

= <EOL> ( this as? AbstractPlatformRandom ) ? . impl ? : KotlinRandom ( this )

/**
 * Creates a [java.util.Random][java.util.Random] instance that uses the specified Kotlin [Random] generator as a randomness source.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public fun java . util . Random . asKotlinRandom ( ) : Random

= <EOL> ( this as? KotlinRandom ) ? . impl ? : PlatformRandom ( this )

/**
 * Creates a Kotlin [Random] instance that uses the specified [java.util.Random][java.util.Random] generator as a randomness source.
 */


protected fun assertPreprocessedTestDataAreEqual ( testServices : TestServices , baseFile : File , baseContent : String , customFile : File , customContent : String , message : ( ) -> String , )

{ <EOL> val processedBaseContent = testServices . sourceFileProvider . getContentOfSourceFile ( TestFile ( baseFile . path , baseContent , baseFile , startLineNumberInOriginalFile = <NUM_LIT:0> , isAdditional = false , RegisteredDirectives . Empty , ) ) . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> val processedLlContent = testServices . sourceFileProvider . getContentOfSourceFile ( TestFile ( customFile . path , customContent , customFile , startLineNumberInOriginalFile = <NUM_LIT:0> , isAdditional = false , RegisteredDirectives . Empty , ) ) . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> testServices . assertions . assertEquals ( processedBaseContent , processedLlContent , message ) <EOL> }

/**
 * Asserts that [baseFile] and [customFile] have the same content after preprocessing (which removes diagnostics and other meta info). This
 * prevents situations where one test data changes, but changes to the other test data are forgotten.
 */


{ <EOL> task . inputs . files ( devMavenRepositoriesInputFiles ) <EOL> . withPropertyName ( "<STR_LIT>" ) <EOL> . withPathSensitivity ( RELATIVE ) <EOL> task . dependsOn ( devMavenRepositories ) <EOL> if ( task is JavaForkOptions ) { <EOL> task . doFirst ( "<STR_LIT>" ) { <EOL> task . systemProperty ( "<STR_LIT>" , devMavenRepositories . joinToString ( "<STR_LIT:U+002C>" ) { it . canonicalFile . invariantSeparatorsPath } ) <EOL> } <EOL> } <EOL> }

/**
 * Configures [task] to register [devMavenRepositories] as a task input,
 * and (if possible) adds `devMavenRepository` as a [JavaForkOptions.systemProperty].
 */


/**
 * [<caret_1>foo]
 *
 * [<caret_2>foo.foo]
 * [foo.<caret_3>foo]
 */


{ <EOL> val output = PrintWriter ( System . out , true ) <EOL> RootCommand . commands . forEach { command -> <EOL> MarkdownPrinter . printUsage ( command , output ) <EOL> } <EOL> }

/**
 * Used for internal purposes to generate documentation.
 * Not an actual test
 */


fun KtAnalysisSession . renderResolvedTo ( symbols : List < KtSymbol > , renderPsiClassName : Boolean = false , renderer : KtDeclarationRenderer = KtDeclarationRendererForDebug . WITH_QUALIFIED_NAMES , additionalInfo : KtAnalysisSession . ( KtSymbol ) -> String ? = { null } ) : String

{ <EOL> if ( symbols . isEmpty ( ) ) return UNRESOLVED_REFERENCE_RESULT <EOL> return symbols . map { renderResolveResult ( it , renderPsiClassName , renderer , additionalInfo ) } <EOL> . sorted ( ) <EOL> . withIndex ( ) <EOL> . joinToString ( separator = "<STR_LIT:\n>" ) { "<STR_LIT>" } <EOL> }

/**
 * Empty [symbols] list equals to unresolved reference.
 */


/**
 * [<caret_1>Foo.ext]
 *
 * [Outer.<caret_2>Foo.ext]
 * [test.Outer.<caret_3>Foo.ext]
 *
 * [test.<caret_4>Foo.ext]
 */


/**
 * [<caret_nested_1>Foo.ext]
 *
 * [Nested.<caret_nested_2>Foo.ext]
 * [Outer.Nested.<caret_nested_3>Foo.ext]
 * [test.Outer.Nested.<caret_nested_4>Foo.ext]
 *
 * [test.<caret_nested_5>Foo.ext]
 */


{ <EOL> val modelHub = <EOL> TFModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val model = TFModels . CV . ResNet50 ( ) . pretrainedModel ( modelHub ) <EOL> model . printSummary ( ) <EOL> model . use { <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:8> ) { <EOL> val imageFile = getFileFromResource ( "<STR_LIT>" ) <EOL> val recognizedObject = it . predictObject ( imageFile = imageFile ) <EOL> println ( recognizedObject ) <EOL> val top5 = it . predictTopKObjects ( imageFile = imageFile , topK = <NUM_LIT:5> ) <EOL> println ( top5 . toString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * This example demonstrates the inference concept on ResNet'50 model:
 * - Model configuration, model weights and labels are obtained from [TFModelHub].
 * - Weights are loaded from .h5 file, configuration is loaded from .json file.
 * - Model predicts on a few images located in resources.
 * - No additional training.
 * - No new layers are added.
 * - Special preprocessing (used in ResNet'50 during training on ImageNet dataset) is applied to each image before prediction.
 */


= resnet50easyPrediction ( )


private fun shouldDoReverseCheck ( overrideCandidate : FirSimpleFunction ) : Boolean

{ <EOL> return ! session . languageVersionSettings . supportsFeature ( LanguageFeature . JavaTypeParameterDefaultRepresentationWithDNN ) && <EOL> overrideCandidate . typeParameters . isNotEmpty ( ) <EOL> }

/**
 * Without [LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN] enabled,
 * the check is unfortunately not symmetrical in a case when the declarations are generic, DNNs are used,
 * and one of them has a flexible upper bound while the other one doesn't.
 *
 * See compiler/testData/diagnostics/tests/j+k/overrideWithTypeParameter.kt
 */


private fun KDoc . findSectionsContainingTag ( tag : KDocKnownTag ) : List < KDocSection >

{ <EOL> return getChildrenOfType < KDocSection > ( ) <EOL> . filter { it . findTagByName ( tag . name . toLowerCaseAsciiOnly ( ) ) != null } <EOL> }

/**
 * Looks for sections that have a deeply nested [tag],
 * as opposed to [KDoc.findSectionByTag], which only looks among the top level
 */


fun BuildResult . getOutputForTask ( taskPath : String , logLevel : LogLevel = LogLevel . DEBUG ) : String

= <EOL> getOutputForTask ( taskPath , output , logLevel )

/**
 * Gets the output produced by a specific task during a Gradle build.
 *
 * @param taskPath The path of the task whose output should be retrieved.
 * @param logLevel The given output contains no more than the [logLevel] logs.
 *
 * @return The output produced by the specified task during the build.
 *
 * @throws IllegalStateException if the specified task path does not match any tasks in the build.
 */


fun getOutputForTask ( taskPath : String , output : String , logLevel : LogLevel = LogLevel . DEBUG ) : String

= ( when ( logLevel ) { <EOL> LogLevel . INFO -> taskOutputRegexForInfoLog ( taskPath ) <EOL> LogLevel . DEBUG -> taskOutputRegexForDebugLog ( taskPath ) <EOL> else -> throw throw IllegalStateException ( "<STR_LIT>" ) <EOL> } ) <EOL> . findAll ( output ) <EOL> . map { it . groupValues [ <NUM_LIT:1> ] } <EOL> . joinToString ( System . lineSeparator ( ) ) <EOL> . ifEmpty { <EOL> error ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> }

/**
 * Gets the output produced by a specific task during a Gradle build.
 *
 * @param taskPath The path of the task whose output should be retrieved.
 * @param output The output from which we should extract task's output
 * @param logLevel The given output contains no more than the [logLevel] logs.
 *
 * @return The output produced by the specified task during the build.
 *
 * @throws IllegalStateException if the specified task path does not match any tasks in the build.
 */


fun BuildResult . extractNativeTasksCommandLineArgumentsFromOutput ( vararg tasksPaths : String , toolName : NativeToolKind = NativeToolKind . KONANC , logLevel : LogLevel = LogLevel . INFO , assertions : CommandLineArguments . ( ) -> Unit , )

= tasksPaths . forEach { taskPath -> <EOL> val taskOutput = getOutputForTask ( taskPath , logLevel ) <EOL> val commandLineArguments = extractNativeCompilerCommandLineArguments ( taskOutput , toolName ) <EOL> assertions ( CommandLineArguments ( commandLineArguments , this ) ) <EOL> }

/**
 * Asserts the command line arguments of the given Kotlin/Native (K/N) compiler for the specified tasks' paths.
 *
 * Note: The log level of the output must be set to [LogLevel.DEBUG].
 *
 * @param tasksPaths The paths of the tasks for which the command line arguments should be checked against the provided assertions.
 * @param toolName The name of the build tool used.
 * @param logLevel The given output contains no more than the [logLevel] logs.
 * @param assertions The assertions to be applied to each command line argument of each given task.
 * These assertions validate the expected properties of the command line arguments.
 * These assertions validate the expected properties of the command line arguments.
 */


fun expanded ( maxCapacity : Int ) : RingBuffer < T >

{ <EOL> val newCapacity = ( capacity + ( capacity shr <NUM_LIT:1> ) + <NUM_LIT:1> ) . coerceAtMost ( maxCapacity ) <EOL> val newBuffer = if ( startIndex == <NUM_LIT:0> ) buffer . copyOf ( newCapacity ) else toArray ( arrayOfNulls ( newCapacity ) ) <EOL> return RingBuffer ( newBuffer , size ) <EOL> }

/**
 * Creates a new ring buffer with the capacity equal to the minimum of [maxCapacity] and 1.5 * [capacity].
 * The returned ring buffer contains the same elements as this ring buffer.
 */


{ <EOL> if ( isFull ( ) ) { <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> buffer [ startIndex . forward ( size ) ] = element <EOL> size ++ <EOL> }

/**
 * Add [element] to the buffer or fail with [IllegalStateException] if no free space available in the buffer
 */


{ <EOL> require ( n >= <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> require ( n <= size ) { "<STR_LIT>" } <EOL> if ( n > <NUM_LIT:0> ) { <EOL> val start = startIndex <EOL> val end = start . forward ( n ) <EOL> if ( start > end ) { <EOL> buffer . fill ( null , start , capacity ) <EOL> buffer . fill ( null , <NUM_LIT:0> , end ) <EOL> } else { <EOL> buffer . fill ( null , start , end ) <EOL> } <EOL> startIndex = end <EOL> size -= n <EOL> } <EOL> }

/**
 * Removes [n] first elements from the buffer or fails with [IllegalArgumentException] if not enough elements in the buffer to remove
 */


{ <EOL> val modelHub = TFModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val modelType = TFModels . CV . VGG19 ( ) <EOL> val model = modelHub . loadModel ( modelType ) <EOL> val fileDataLoader = modelType . createPreprocessing ( model ) . fileLoader ( ) <EOL> val imageNetClassLabels = modelHub . loadClassLabels ( ) <EOL> var copiedModel : Sequential <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . MAE , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> val hdfFile = modelHub . loadWeights ( modelType ) <EOL> it . loadWeights ( hdfFile ) <EOL> copiedModel = it . copy ( copyWeights = true ) <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:8> ) { <EOL> val inputData = fileDataLoader . load ( getFileFromResource ( "<STR_LIT>" ) ) <EOL> val res = it . predictLabel ( inputData ) <EOL> println ( "<STR_LIT>" ) <EOL> val top5 = it . predictTop5Labels ( inputData , imageNetClassLabels ) <EOL> println ( top5 . toString ( ) ) <EOL> } <EOL> } <EOL> copiedModel . use { <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:8> ) { <EOL> val inputData = fileDataLoader . load ( getFileFromResource ( "<STR_LIT>" ) ) <EOL> val res = it . predictLabel ( inputData ) <EOL> println ( "<STR_LIT>" ) <EOL> val top5 = it . predictTop5Labels ( inputData , imageNetClassLabels ) <EOL> println ( top5 . toString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * This example demonstrates the inference concept on VGG'19 model:
 * - Model configuration, model weights and labels are obtained from [TFModelHub].
 * - Weights are loaded from .h5 file, configuration is loaded from .json file.
 * - Model predicts on a few images located in resources.
 * - Special preprocessing (used in VGG'19 during training on ImageNet dataset) is applied to each image before prediction.
 * - No additional training.
 * - No new layers are added.
 * - Model copied and used for prediction.
 *
 * @see
 * Very Deep Convolutional Networks for Large-Scale Image Recognition (ICLR 2015).
 * @see
 * Detailed description of VGG'19 model and an approach to build it in Keras.
 */


= vgg19copyModelPrediction ( )


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public actual fun < T : Comparable < T > > maxOf ( a : T , b : T ) : T

{ <EOL> return if ( a >= b ) a else b <EOL> }

/**
 * Returns the greater of two values.
 *
 * If values are equal, returns the first one.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Byte , b : Byte ) : Byte

{ <EOL> return maxOf ( a . toInt ( ) , b . toInt ( ) ) . toByte ( ) <EOL> }

/**
 * Returns the greater of two values.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Short , b : Short ) : Short

{ <EOL> return maxOf ( a . toInt ( ) , b . toInt ( ) ) . toShort ( ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Int , b : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Long , b : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Float , b : Float ) : Float

{ <EOL> return if ( a . compareTo ( b ) >= <NUM_LIT:0> ) a else b <EOL> }

/**
 * Returns the greater of two values.
 *
 * If either value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Double , b : Double ) : Double


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public actual fun < T : Comparable < T > > maxOf ( a : T , b : T , c : T ) : T

{ <EOL> return maxOf ( a , maxOf ( b , c ) ) <EOL> }

/**
 * Returns the greater of three values.
 *
 * If there are multiple equal maximal values, returns the first of them.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Byte , b : Byte , c : Byte ) : Byte

{ <EOL> return maxOf ( a . toInt ( ) , maxOf ( b . toInt ( ) , c . toInt ( ) ) ) . toByte ( ) <EOL> }

/**
 * Returns the greater of three values.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Short , b : Short , c : Short ) : Short

{ <EOL> return maxOf ( a . toInt ( ) , maxOf ( b . toInt ( ) , c . toInt ( ) ) ) . toShort ( ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Int , b : Int , c : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Long , b : Long , c : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Float , b : Float , c : Float ) : Float

/**
 * Returns the greater of three values.
 *
 * If any value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun maxOf ( a : Double , b : Double , c : Double ) : Double


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun < T : Comparable < T > > maxOf ( a : T , vararg other : T ) : T

{ <EOL> var max = a <EOL> for ( e in other ) max = maxOf ( max , e ) <EOL> return max <EOL> }

/**
 * Returns the greater of the given values.
 *
 * If there are multiple equal maximal values, returns the first of them.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Byte , vararg other : Byte ) : Byte

/**
 * Returns the greater of the given values.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Short , vararg other : Short ) : Short


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Int , vararg other : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Long , vararg other : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Float , vararg other : Float ) : Float

/**
 * Returns the greater of the given values.
 *
 * If any value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun maxOf ( a : Double , vararg other : Double ) : Double


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public actual fun < T : Comparable < T > > minOf ( a : T , b : T ) : T

{ <EOL> return if ( a <= b ) a else b <EOL> }

/**
 * Returns the smaller of two values.
 *
 * If values are equal, returns the first one.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Byte , b : Byte ) : Byte

{ <EOL> return minOf ( a . toInt ( ) , b . toInt ( ) ) . toByte ( ) <EOL> }

/**
 * Returns the smaller of two values.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Short , b : Short ) : Short

{ <EOL> return minOf ( a . toInt ( ) , b . toInt ( ) ) . toShort ( ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Int , b : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Long , b : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Float , b : Float ) : Float

{ <EOL> return when { <EOL> a . isNaN ( ) -> a <EOL> b . isNaN ( ) -> b <EOL> else -> if ( a . compareTo ( b ) <= <NUM_LIT:0> ) a else b <EOL> } <EOL> }

/**
 * Returns the smaller of two values.
 *
 * If either value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Double , b : Double ) : Double


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public actual fun < T : Comparable < T > > minOf ( a : T , b : T , c : T ) : T

{ <EOL> return minOf ( a , minOf ( b , c ) ) <EOL> }

/**
 * Returns the smaller of three values.
 *
 * If there are multiple equal minimal values, returns the first of them.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Byte , b : Byte , c : Byte ) : Byte

{ <EOL> return minOf ( a . toInt ( ) , minOf ( b . toInt ( ) , c . toInt ( ) ) ) . toByte ( ) <EOL> }

/**
 * Returns the smaller of three values.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Short , b : Short , c : Short ) : Short

{ <EOL> return minOf ( a . toInt ( ) , minOf ( b . toInt ( ) , c . toInt ( ) ) ) . toShort ( ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Int , b : Int , c : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Long , b : Long , c : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Float , b : Float , c : Float ) : Float

/**
 * Returns the smaller of three values.
 *
 * If any value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun minOf ( a : Double , b : Double , c : Double ) : Double


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun < T : Comparable < T > > minOf ( a : T , vararg other : T ) : T

{ <EOL> var min = a <EOL> for ( e in other ) min = minOf ( min , e ) <EOL> return min <EOL> }

/**
 * Returns the smaller of the given values.
 *
 * If there are multiple equal minimal values, returns the first of them.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Byte , vararg other : Byte ) : Byte

/**
 * Returns the smaller of the given values.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Short , vararg other : Short ) : Short


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Int , vararg other : Int ) : Int


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Long , vararg other : Long ) : Long


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Float , vararg other : Float ) : Float

/**
 * Returns the smaller of the given values.
 *
 * If any value is `NaN`, returns `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public actual fun minOf ( a : Double , vararg other : Double ) : Double


@ Test <EOL> fun testAwaitingRacingWithCompletion ( )

= runTest { <EOL> val mono = object : Mono < Int > ( ) { <EOL> override fun subscribe ( s : CoreSubscriber < in Int > ) { <EOL> s . onSubscribe ( object : Subscription { <EOL> override fun request ( n : Long ) { <EOL> thread = thread { <EOL> s . onNext ( <NUM_LIT:1> ) <EOL> Thread . yield ( ) <EOL> completed = true <EOL> s . onComplete ( ) <EOL> } <EOL> } <EOL> override fun cancel ( ) { <EOL> } <EOL> } ) <EOL> } <EOL> } <EOL> repeat ( N_REPEATS ) { <EOL> thread = null <EOL> completed = false <EOL> val value = mono . awaitSingleOrNull ( ) <EOL> assertTrue ( completed , "<STR_LIT>" ) <EOL> assertEquals ( <NUM_LIT:1> , value ) <EOL> thread ! ! . join ( ) <EOL> } <EOL> }

/**
 * Tests that [Mono.awaitSingleOrNull] does await [CoreSubscriber.onComplete] and does not return
 * the value as soon as it has it.
 */


@ OptIn ( ObsoleteDescriptorBasedAPI :: class ) <EOL> fun IrProperty . analyzeIfFromAnotherModule ( ) : Pair < Boolean , Boolean >

{ <EOL> return if ( descriptor is DeserializedPropertyDescriptor ) { <EOL> val hasDefault = descriptor . declaresDefaultValue ( ) <EOL> hasDefault to ( descriptor . backingField != null || hasDefault ) <EOL> } else if ( this is Fir2IrLazyProperty ) { <EOL> val hasBackingField = fir . symbol . registeredInSerializationPluginMetadataExtension <EOL> val matchingPrimaryConstructorParam = containingClass ? . declarations ? . filterIsInstance < FirPrimaryConstructor > ( ) <EOL> ? . singleOrNull ( ) ? . valueParameters ? . find { it . name == this . name } <EOL> if ( matchingPrimaryConstructorParam != null ) { <EOL> ( matchingPrimaryConstructorParam . defaultValue != null ) to hasBackingField <EOL> } else { <EOL> ( fir . getter is FirDefaultPropertyGetter ) to hasBackingField <EOL> } <EOL> } else { <EOL> false to false <EOL> } <EOL> }

/**
 * This function checks if a deserialized property declares default value and has backing field.
 *
 * Returns (declaresDefaultValue, hasBackingField) boolean pair. Returns (false, false) for properties from current module.
 */