Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121980231
OneDTab.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 04:32
Size
1 KB
Mime Type
text/x-c
Expires
Thu, Jul 17, 04:32 (2 d)
Engine
blob
Format
Raw Data
Handle
27420627
Attached To
R1695 PCSC - Numerical Integration - Ollitrault Rouaze
OneDTab.cpp
View Options
//
// Created by Pauline Ollitrault on 28.11.16.
//
#include "OneDTab.hpp"
/**
* @brief Default constructor
*/
OneDTab::OneDTab(){}
/**
* @brief Alternate constructor that sets the function
* @details Calls the @e SetFunction() method with the string passed as argument.
* @param function string containing the name of the data file.
*/
OneDTab::OneDTab(const std::string function) : AbstractTabFunction()
{
SetFunction(function);
}
/**
* @brief Sets the function to be integrated
* @details Reads the data from file and stores in X and Y vectors. Returns an error is the number
* of nodes is not greater than one.
* @param function string containing the name of the data file.
*/
void OneDTab::SetFunction(const std::string function)
{
std::ifstream read_file(function);
try {
if (!read_file.is_open())
{
throw Error("Error opening data file : ");
}
}
catch(Error err)
{
std::cerr << "ERROR : " << err.what() << function <<std::endl;
exit(0);
}
double x;
double y;
while(!read_file.eof())
{
read_file >> x >> y;
X.push_back(x);
Y.push_back(y);
}
read_file.close();
try {
if (X.size() <= 1 or Y.size() <=1)
{
throw Error("Number of nodes must be greater than 1.");
}
}
catch(Error err)
{
std::cerr << "ERROR : " << err.what() << std::endl;
exit(0);
}
}
Event Timeline
Log In to Comment