/********************************************************
* ██████╗ ██████╗████████╗██╗
* ██╔════╝ ██╔════╝╚══██╔══╝██║
* ██║ ███╗██║ ██║ ██║
* ██║ ██║██║ ██║ ██║
* ╚██████╔╝╚██████╗ ██║ ███████╗
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see .
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#ifndef _GCTL_EXTRAPOLATE_H
#define _GCTL_EXTRAPOLATE_H
#include "../core/array.h"
#include "../core/matrix.h"
#include "../maths/mathfunc_t.h"
namespace gctl
{
/**
* @brief 使用cosine函数对一维数组进行外插
*
* @param in_arr 输入数组
* @param[in] in_num 数组长度
* @param out_arr 输出数组
* @param[in] out_num 数组长度
* @param[in] end_value 外插后的端点值,若为NAN则函数会计算原数组端点值的均值作为新的端点值
*/
void cosine_extrapolate_1d(double *in_arr, int in_num, double *out_arr, int out_num, double end_value = NAN);
/**
* @brief 使用cosine函数对一维数组进行外插
*
* @param[in] in_arr 输入数组
* @param out_arr 输出数组
* @param[in] end_val 外插后的端点值,若输入值为NAN函数会计算原数组端点值的均值作为新的端点值
* @param[in] out_len 外插后的数组长度,若输入值小于0函数会计算最小的2的次方值作为输出的数组长度
*/
void cosine_extrapolate_1d(const array &in_arr, array &out_arr, double end_val = NAN, int out_len = -1);
/**
* @brief 使用cosine函数对二维数组进行外插
*
* @param[in] in_arr 输入数组
* @param out_arr 输出数组
* @param ori_row 原数据在扩边后的起始行号
* @param ori_col 原数据在扩边后的起始列号
* @param[in] end_valx x方向外插后的端点值,若输入值为NAN函数会计算原数组端点值的均值作为新的端点值
* @param[in] end_valy y方向外插后的端点值,若输入值为NAN函数会计算原数组端点值的均值作为新的端点值
* @param[in] out_lenx x方向外插后的数组长度,若输入值小于0函数会计算最小的2的次方值作为输出的数组长度
* @param[in] out_leny y方向外插后的数组长度,若输入值小于0函数会计算最小的2的次方值作为输出的数组长度
*/
void cosine_extrapolate_2d(const _2d_matrix &in_arr, _2d_matrix &out_arr,
int &ori_row, int &ori_col, double end_valx = NAN, double end_valy = NAN, int out_lenx = -1, int out_leny = -1);
/**
* @brief 使用cosine函数对二维数组进行外插
*
* 按一维数组排列(列优先,按行排列)
*
* @param[in] in_arr 输入数组
* @param out_arr 输出数组
* @param[in] in_row 输入数组的行数
* @param[in] in_col 输入数组的列数
* @param out_row 输出数组的行数(如果输入值为负则函数会计算最小的2的次方值作为输出的行数,否则即按照输入值进行扩边)
* @param out_col 输出数组的列数(如果输入值为负则函数会计算最小的2的次方值作为输出的行数,否则即按照输入值进行扩边)
* @param ori_row 原数据在扩边后的起始行号
* @param ori_col 原数据在扩边后的起始列号
* @param[in] end_valx x方向外插后的端点值,若输入值为NAN函数会计算原数组端点值的均值作为新的端点值
* @param[in] end_valy y方向外插后的端点值,若输入值为NAN函数会计算原数组端点值的均值作为新的端点值
*/
void cosine_extrapolate_2d(const array &in_arr, array &out_arr, int in_row, int in_col,
int &out_row, int &out_col, int &ori_row, int &ori_col, double end_valx = NAN, double end_valy = NAN);
/**
* @brief 使用零值对二维数组进行外插
*
* 按一维数组排列(列优先,按行排列)
*
* @param[in] in_arr 输入数组
* @param out_arr 输出数组
* @param[in] in_row 输入数组的行数
* @param[in] in_col 输入数组的列数
* @param out_row 输出数组的行数(如果输入值为负则函数会计算最小的2的次方值作为输出的行数,否则即按照输入值进行扩边)
* @param out_col 输出数组的列数(如果输入值为负则函数会计算最小的2的次方值作为输出的行数,否则即按照输入值进行扩边)
* @param ori_row 原数据在扩边后的起始行号
* @param ori_col 原数据在扩边后的起始列号
*/
void zeros_extrapolate_2d(const array &in_arr, array &out_arr, int in_row, int in_col,
int &out_row, int &out_col, int &ori_row, int &ori_col);
}
#endif // _GCTL_EXTRAPOLATE_H