Costas arrays searching algorithm based on vectors

Costas arrays have been widely applied in wireless communication, radar and cryptography as they have the ideal auto-ambiguity properties. Costas arrays are constructed mostly using the algebraic method, or they can be found by exhaustive search. This paper first introduces the Costas arrays and their properties and then proposes the vector-based algorithm to make depth-first search for Costas arrays since the exhaustive search algorithm based on check matrix is flawed. The experiment results indicate that the algorithm based on vectors has higher search speed on a single CPU when compared with the exhaustive searching algorithm based on check matrix.


Introduction
In the 1960's, John P. Costas proposed the concept of frequency hopping signals characterized by ideal autoambiguity when he attempted to design sonar signals to improve the performance of sonar systems [1]. A frequency hopping array with an ideal autocorrelation function is also called Costas array. In the 1980's, S.W. Golomb constructed the Costas arrays based on the finite field theory [2]. Another way to obtain the Costas arrays is exhaustive search through the computer program [3].
Let P be an order n permutation matrix. If the maximum value of the side lobe of the auto-correlation function R(τ,d) is equal to 1, the matrix P is called an order n Costas array [4]. Dots and blanks are usually used to represent 1 and 0 in the permutation matrix, respectively. For example, what is shown in Figure 1 is a Costas array and its auto-correlation is presented in Figure 2. We find that it has ideal auto-correlation properties, the main lobe is high and sharp while the side lobes are low and flat [5]. The Costas arrays are not only applied to radar [6], but also have a wide range of applications in wireless communication and cryptography [7]. Therefore, it is of great significance to conduct research on the construction of Costas arrays and the algorithm for searching Costas arrays.
A Costas arrays searching algorithm based on a check matrix is proposed in [8]. The backtracking method [9] is used to exhaustively enumerate order n permutation matrix P, when any column in the check matrix D does not have the same element, then the order n permutation matrix P is a Costas array. The algorithm has the following disadvantages:  • The backtracking method is used to traverse n! permutation matrices. When the order n is high, the number of permutation matrices is large, and the computation increases dramatically.
• The check matrix is used to determine whether P is a Costas array. The performance is not good if the order is high.
Given the shortcomings of the searching algorithm based on check matrix and the properties of Costas arrays, a Costas arrays searching algorithm based on vectors is proposed in this paper. Firstly, the determination of permutation matrix and whether it meets the criterion of Costas arrays contributes to the elimination of the shortcomings of the backtracking method that traverses all permutation matrices, hence reducing unnecessary calculations. Secondly, the optimization of Costas arrays criterion reduces the time complexity of the algorithm. Finally, the experiment results indicate that the algorithm proposed in this paper accelerates the searching of the Costas arrays on a single CPU.

Permutation matrix
Each permutation of n elements corresponds to a unique permutation matrix. Let be a permutation of n elements: : 1, ⋯ , → 1, ⋯ , Represented in two-line form: where the entries in row i are all 0 except that a 1 appears in column . That can be written as: ⋮ where e , a standard basis vector, denotes a row vector of length n with 1 in the column j and 0 in every other position.
From the above definition of the permutation matrix, it can be seen that for the permutation matrix, there are only a single 1 in each row and column.
In the algorithm proposed in this paper, an order n permutation matrix is represented by a one-dimensional array of length n. Each element represents a row, and the value of the element represents the column value of 1 in the row. This is sufficient to fully represent the permutation matrix and avoid any scanning of rows. For example: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 It can be expressed as 4 2 3 1 The position of the column where the row before the row i of the permutation matrix has been used is represented by the variable dotUsed. The column value j of the row i to be filled in is represented by the variable dot, where j = 1 ≪ i. Computes the bitwise and of the variable bitUsed and dot, and the obtained result is judged so that the row i can satisfy the correct position of 1 defined by the permutation matrix. A bitwise or of the variable dotUsed and dot results in the position of the column where the row before row i+1 has been used. The permutation matrix can be obtained by recursion.
When searching the permutation matrix, whether it satisfies the Costas arrays criterion is judged, and if it does not satisfy the condition, there is no need to continue downward recursion. Therefore, searching for the Costas arrays does not need to exhaust the n! probability of the order n matrix P, which avoids the use of backtracking method to traverse all permutation matrices and reduces unnecessary calculations.

Costas arrays judgement criterion
Costas arrays have many properties. For example, when a Costas array is rotated 90°, and flipped horizontally, vertically, and diagonally, it is still a Costas array [10,11]. This property can be used to optimize the criterion of the Costas arrays. If a permutation matrix is a Costas array and its symmetric array is also a Costas array, there is no need to judge all cases.
Another property of the Costas arrays is mentioned in [12,13]. Let C={1, 2, …, n} be a set of n elements, where n∈ . f is a permutation on C, and f is Costas permutation if and only if it satisfies the following conditions: ∀ , , , where , , ∈ : The Costas array is the permutation matrix that corresponds to the Costas permutation.
Customarily, 1 is represented as dot in the permutation matrix and 0 is represented as blank. From the perspective of vectors, equation (1) can be seen as the vector (f(j)-f(i), j -i) between the dots of the column i and the column j of the Costas array, which is not repeated between any other pairs of dots, where 1≤i,j≤n. From a geometrical point of view, equation (1) means that four dots that are not on a straight line cannot form a parallelogram, as the array shown in Figure 3, and four dots form a parallelogram, so this array is not a Costas array; four dots on a straight line cannot form two pairs of equidistant dots, as the array shown in Figure 4, and there are two pairs of equidistant dots, so it is not a Costas array; three dots on a straight line cannot be equidistant, as the array shown in Figure 5, three dots are in a straight line and equidistant, so it is not a Costas array.   Based on the understanding of the above properties, the vector is introduced into the judgement of the Costas arrays. The vector is used to judge whether a permutation matrix is a Costas array. The vectors for the dot on the row n and all previous rows are calculated and the position is recorded in the corresponding position in the array vectorLocation. The purpose of this array is to ensure that any particular vector can only occur once. If any vector is already in the array, indicating that the permutation matrix cannot constitute a Costas array, the dot in current row is invalid and it will be skipped.

Algorithm idea
Depth-first search is to select a vertex in a given graph as the starting point of the search, then search for unmarked adjacency points, from which the recursive search is made until all the vertices have been searched.
Based on the idea of depth-first search, each possible position is tried from the first row of the permutation matrix and recursively to the next row to select the point that satisfies the permutation matrix condition. At the same time, it is judged whether or not it meets the criterion of Costas arrays. If not, another dot of this row is selected again and it is judged whether it satisfies the above two requirements. Otherwise, it continues recursively to the next row until all rows have been searched. If all rows are verified, the array is a Costas array. So it returns 1. Finally all the Costas arrays that meet the conditions are added up. The final result of recursion is the total number of Costas arrays.
The specific flow of the algorithm proposed in this paper is as follows: Input: the order of Costas arrays Output: the total number of Costas arrays of specific order and time

Experiment and result analysis
Experimental environment: The operating system is Windows 7 64-bits, the processor is Intel(R) Core(TM) i5-4460 3.2GHz 4 cores, the memory is 8.0 GB, the integrated development environment is CLion, and the algorithm is implemented using C language. The experiments with the algorithm presented in [8] and the algorithm proposed in this paper were performed respectively. The results are shown in Table 1 and Table  2, respectively. Table 1. The result of the algorithm in [8] Comparing Table 1 and Table 2, we can see that the algorithm presented in [8] and the algorithm proposed in this paper can correctly calculate the number of Costas arrays of a given order. However, as can be seen from Figure 6, the searching speed of the algorithm proposed in this paper is significantly increased. Therefore, the experimental dataset verifies the effectiveness of the algorithm based on vectors in increasing the speed of arrays search. In addition, it can be seen from Figure 7 that the number of Costas arrays does not increase with the increase of the order. When the order is 16, it reaches the peak and then gradually decreases. When the order is changed from n to n+1, the calculation is increased by about 6 times. Therefore, this experiment only searches the Costas arrays whose order is not greater than 19, and it can be roughly estimated that when the order is greater than 19, searching the Costas arrays will take several months.

Conclusions
This paper proposes a vectors-based Costas arrays searching algorithm as the existing Costas arrays searching algorithm has a high time complexity and a low searching speed for higher order. The algorithm introduces vectors and determines whether the array is a Costas array by comparing vectors. Furthermore, it overcomes the drawbacks of the backtracking method that exhausts all the permutation matrices. The results of the experiment that compares the two algorithms show that the algorithm proposed in this paper is effective in increasing the search speed of Costas arrays dramatically.
In addition, we also find that the number of Costas arrays does not increase with the increase of the order, and it reaches the peak when the order is 16. When the order is increased by 1, the computation of Costas arrays search increases by approximately 6 times.