time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

ccopy.c (1583B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2020 The Stdlib Authors.
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *    http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 #include "stdlib/blas/base/ccopy.h"
     20 
     21 /**
     22 * Copies values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
     23 *
     24 * @param N        number of elements to copy
     25 * @param X        input array
     26 * @param strideX  X stride length
     27 * @param Y        destination array
     28 * @param strideY  Y stride length
     29 */
     30 void c_ccopy( const int N, const void *X, const int strideX, void *Y, const int strideY ) {
     31 	float *x = (float *)X;
     32 	float *y = (float *)Y;
     33 	int ix;
     34 	int iy;
     35 	int i;
     36 
     37 	if ( N <= 0 ) {
     38 		return;
     39 	}
     40 	if ( strideX == 1 && strideY == 1 ) {
     41 		for ( i = 0; i < N*2; i += 2 ) {
     42 			y[ i ] = x[ i ];
     43 			y[ i+1 ] = x[ i+1 ];
     44 		}
     45 		return;
     46 	}
     47 	if ( strideX < 0 ) {
     48 		ix = 2 * (1-N) * strideX;
     49 	} else {
     50 		ix = 0;
     51 	}
     52 	if ( strideY < 0 ) {
     53 		iy = 2 * (1-N) * strideY;
     54 	} else {
     55 		iy = 0;
     56 	}
     57 	for ( i = 0; i < N; i++ ) {
     58 		y[ iy ] = x[ ix ];
     59 		y[ iy+1 ] = x[ ix+1 ];
     60 		ix += strideX * 2;
     61 		iy += strideY * 2;
     62 	}
     63 	return;
     64 }