ADExpression
with two pure virtual functions:
double evaluate()
: This function returns the value of the variable.double derivative()
: This function returns the derivative of the variable.Scalar
that inherits from ADExpression
. This class represents a scalar variable and its derivative.ADExpression
:
Sum
: Represents the addition of two ADExpression
objects.Difference
: Represents the subtraction of two ADExpression
objects.Product
: Represents the multiplication of two ADExpression
objects.Division
: Represents the division of two ADExpression
objects.Power
: Represents raising an ADExpression
object to a constant exponent.main
function, demonstrate the usage of these classes.In the context of data analysis, create a C++ program that models different types of data sources and transformation objects.
DataSource
with attributes and methods that represent common properties of data sources. Create derived classes such as FileDataSource
and ConsoleDataSource
.DataTransformer
with a virtual method for data transformation. Create derived classes such as LinearScaler
, LogTransformer
, and StandardScaler
that implement specific data transformation methods.DataSource
with a string attribute name
, a vector data
, a method display_info()
and a pure virtual method read_data()
.DataSource
class with.FileDataSource
and ConsoleDataSource
that inherit from DataSource
.FileDataSource
should initialize a filename
and an input file, ConsoleDataSource
should have a default constructor.FileDataSource
constructor should open the file, and its destructor should close it.read_data()
methods. FileDataSource::read_data()
should import values from a file (see data.txt
as an example), whereas ConsoleDataSource::read_data()
should read a list of values from the standard input.FileDataSource
object and call display_info()
and read_data()
methods to read and display data from a file.DataTransformer
, bound to DataSource
by polymorphic composition. DataTransformer
should have a pure virtual method transform()
that transforms the data
vector in the corresponding DataSource
.LinearScaler
, LogTransformer
, and StandardScaler
that inherit from DataTransformer
.transform()
method in each derived class to provide specific data transformation. For example, LinearScaler
scales the data by multiplying them by a given scaling factor, LogTransformer
applies a logarithmic transformation and sets negative entries to 0
, and StandardScaler
performs standardization to the DataSource
object.DataSource
and the DataTransformer
hierarchy polymorphically. In particular, the program should prompt the user to import data either from a file or from console, and to select the transformation method.FileDataSource
is selected, prompt the user to specify the filename from the console.LinearScaler
is selected, prompt the user to specify the scaling factor from the console.DataSource
hierarchy to import a given field from an input CSV
file (see data.csv
as an example).CSV
file with the transformed ones.