add data functions to negate data
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
<headers dist="true" install="$(pkgincludedir)/data">
|
||||
average.h
|
||||
accumulate.h
|
||||
negate.h
|
||||
floatingavg.h
|
||||
date.h
|
||||
diff.h
|
||||
@@ -72,6 +73,7 @@
|
||||
$(local/typefiles)
|
||||
average.c
|
||||
accumulate.c
|
||||
negate.c
|
||||
floatingavg.c
|
||||
date.c
|
||||
diff.c
|
||||
|
||||
105
src/lib/aqdiagram/data/negate.c
Normal file
105
src/lib/aqdiagram/data/negate.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqDiagram.
|
||||
* AqDiagram (c) by 2025 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "./negate.h"
|
||||
|
||||
|
||||
|
||||
AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_NegateY(const AQDG_GRAPH_DATAPAIR_LIST *dpList)
|
||||
{
|
||||
if (dpList && AQDG_Graph_DataPair_List_GetCount(dpList)) {
|
||||
AQDG_GRAPH_DATAPAIR_LIST *newList;
|
||||
const AQDG_GRAPH_DATAPAIR *dp;
|
||||
|
||||
newList=AQDG_Graph_DataPair_List_new();
|
||||
dp=AQDG_Graph_DataPair_List_First(dpList);
|
||||
while(dp) {
|
||||
AQDG_GRAPH_DATAPAIR *newDp;
|
||||
double v;
|
||||
|
||||
v=AQDG_Graph_DataPair_GetValueY(dp);
|
||||
newDp=AQDG_Graph_DataPair_dup(dp);
|
||||
AQDG_Graph_DataPair_SetValueY(newDp, -v);
|
||||
AQDG_Graph_DataPair_List_Add(newDp, newList);
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_NegateX(const AQDG_GRAPH_DATAPAIR_LIST *dpList)
|
||||
{
|
||||
if (dpList && AQDG_Graph_DataPair_List_GetCount(dpList)) {
|
||||
AQDG_GRAPH_DATAPAIR_LIST *newList;
|
||||
const AQDG_GRAPH_DATAPAIR *dp;
|
||||
|
||||
newList=AQDG_Graph_DataPair_List_new();
|
||||
dp=AQDG_Graph_DataPair_List_First(dpList);
|
||||
while(dp) {
|
||||
AQDG_GRAPH_DATAPAIR *newDp;
|
||||
double v;
|
||||
|
||||
v=AQDG_Graph_DataPair_GetValueX(dp);
|
||||
newDp=AQDG_Graph_DataPair_dup(dp);
|
||||
AQDG_Graph_DataPair_SetValueX(newDp, -v);
|
||||
AQDG_Graph_DataPair_List_Add(newDp, newList);
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQDG_Data_NegateInPlaceY(AQDG_GRAPH_DATAPAIR_LIST *dpList)
|
||||
{
|
||||
if (dpList && AQDG_Graph_DataPair_List_GetCount(dpList)) {
|
||||
AQDG_GRAPH_DATAPAIR *dp;
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_First(dpList);
|
||||
while(dp) {
|
||||
double v;
|
||||
|
||||
v=AQDG_Graph_DataPair_GetValueY(dp);
|
||||
AQDG_Graph_DataPair_SetValueY(dp, -v);
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQDG_Data_NegateInPlaceX(AQDG_GRAPH_DATAPAIR_LIST *dpList)
|
||||
{
|
||||
if (dpList && AQDG_Graph_DataPair_List_GetCount(dpList)) {
|
||||
AQDG_GRAPH_DATAPAIR *dp;
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_First(dpList);
|
||||
while(dp) {
|
||||
double v;
|
||||
|
||||
v=AQDG_Graph_DataPair_GetValueX(dp);
|
||||
AQDG_Graph_DataPair_SetValueX(dp, -v);
|
||||
|
||||
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
37
src/lib/aqdiagram/data/negate.h
Normal file
37
src/lib/aqdiagram/data/negate.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqDiagram.
|
||||
* AqDiagram (c) by 2025 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQDG_DATA_NEGATE_H
|
||||
#define AQDG_DATA_NEGATE_H
|
||||
|
||||
#include <aqdiagram/graph/datapair.h>
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
AQDG_API AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_NegateY(const AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||
AQDG_API AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_NegateX(const AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||
|
||||
AQDG_API void AQDG_Data_NegateInPlaceY(AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||
AQDG_API void AQDG_Data_NegateInPlaceX(AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user