本文整理汇总了C++中SC_DoubleArray类的典型用法代码示例。如果您正苦于以下问题:C++ SC_DoubleArray类的具体用法?C++ SC_DoubleArray怎么用?C++ SC_DoubleArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SC_DoubleArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRadialParValue
bool Parameter::GetRadialParValue(const SC_DoubleArray& rVal,
SC_DoubleArray& parVals,
SC_SetupErr& errData)
{
// sanity
if (!IsRadial())
GenAppInternalError("Parameter::GetRadialParValue");
parVals.AllocAndSetSize(rVal.Size());
if (IsPoints())
{
if (rPointsCurve == 0)
GenAppInternalError("Parameter::GetRadialParValue_1");
if (!rPointsCurve->CurveOK(errData))
return false;
for (int i = 0; i < rVal.Size(); i++)
parVals[i] = rPointsCurve->GetMetricPointCurveY(rVal[i]);
}
else
{
for (int i = 0; i < rVal.Size(); i++)
parVals[i] = rFixedCurve.GetMetricFileCurveY(rVal[i]);
}
return true;
}
示例2: GenAppWarningMsg
void XYGridControl::PasteFromClipboardXY(int nIndexFrom)
{
int nIndex = nIndexFrom;
PS_Import import;
if (!import.OpenClipboardImport())
{
GenAppWarningMsg("XYGridControl", "Can't open clipboard");
return;
}
SC_DoubleArray xyRowData;
while (import.GetLineDoubles(xyRowData))
{
if (xyRowData.Size() > 1)
{
xyData.SetAtGrow(nIndex, XYItem(xyRowData[0], xyRowData[1]));
nIndex++;
}
}
import.CloseImport();
int nCount = nIndex - nIndexFrom;
CString strInfo;
strInfo.Format("Imported %d rows from clipboard", nCount);
GenAppInfoMsg("XYGridControl", strInfo);
}
示例3: MapDataToRange
bool DC_DataLimit::MapDataToRange(const SC_DoubleArray& inData,
SC_IntArray& outMap,
bool clipToRange) const
{
outMap.Alloc(inData.Size());
actMin = minLimit;
actMax = maxLimit;
if (clipToRange && logRange)
{
actMin = log10(actMin);
actMax = log10(actMax);
}
bool oneOK = false;
for (int i = 0; i < inData.Size(); i++)
{
double dataVal = inData[i];
if (!TransformValueForRange(dataVal, clipToRange))
{
outMap[i] = -1;
continue;
}
int nodeMap = 0;
if (clipToRange && ((dataVal < actMin) || (dataVal > actMax)))
nodeMap = -1;
oneOK = oneOK || (nodeMap == 0);
outMap[i] = nodeMap;
}
return oneOK;
}
示例4: SetExtraction
void RadiusPressureExtraction::SetExtraction(const SC_DoubleArray& nodeRadii,
const double& capRadius)
{
doScale = false;
// special cases first
if (capRadius <= nodeRadii[0])
{
radIndex = 0;
weight = 1.0;
return;
}
if (capRadius >= nodeRadii.LastIndex())
{
radIndex = nodeRadii.Size() - 2;
weight = 0.0;
return;
}
for (int i = 1; i < nodeRadii.Size(); i++)
if (capRadius < nodeRadii[i])
{
radIndex = i - 1;
weight = 1.0 - (capRadius - nodeRadii[i - 1]) / (nodeRadii[i] - nodeRadii[i - 1]);
return;
}
// ??? ouch
GenAppInternalError("RadiusPressureExtraction::SetExtraction");
}
示例5:
void OGL3DBase::TransformIncrements(bool axisIsLog,
const SC_DoubleArray& inIncs,
SC_DoubleArray& tranIncs)
{
tranIncs = inIncs;
if (axisIsLog)
for (int i = 0; i < tranIncs.Size(); i++)
tranIncs[i] = log10(inIncs[i]);
}
示例6: CalcMode
void SC_Statistics::CalcMode(const SC_DoubleArray& data)
{
if (nOK == 0)
return;
// min == max
if (realResults[soVar] < stdEps)
{
realResults[soMode] = realResults[soMean];
return;
}
// Scott, 1979 algorithm for bin width
// W = (3.49)(std.dev.)[(#samples)^(-1/3)]
double width = 3.49 * realResults[soStdDev] * (pow(realResults[soN], -0.3333));
if (width < stdEps)
{
realResults[soMode] = realResults[soMean];
return;
}
double maxNBins = (realResults[soMax] - realResults[soMin]) / width;
if (maxNBins > 10000.0)
return;
int nbins = int(ceil(maxNBins));
// note just linear bins
width = (realResults[soMax] - realResults[soMin]) / double(nbins);
SC_IntArray binCount(nbins, 0);
for (int i = 0; i < data.Size(); i++)
{
double dVal = data[i];
if (RealIsNull(dVal) || (dVal < realResults[soMin])) // can happen if stats calc was log
continue;
int binIndex = int(floor((dVal - realResults[soMin]) / width));
// pathological case == maxVal
if (binIndex == nbins)
binIndex--;
binCount[binIndex]++;
}
int maxBin = 0;
int maxCount = binCount[0];
for (int i = 1; i < nbins; i++)
if (binCount[i] > maxCount)
{
maxBin = i;
maxCount = binCount[i];
}
realResults[soMode] = realResults[soMin] + (double(maxBin) + 0.5) * width;
}
示例7: DoNormalize
void DC_Normalize::DoNormalize(SC_DoubleArray& inData)
{
if (normalizeOp != noPower)
{
if (autoLimit)
{
inData.CalcMinMax(inputMinimum, inputMaximum);
if (RealIsNull(inputMinimum))
return;
}
if (fabs(inputMaximum - inputMinimum) < stdEps)
spanMult = 0.0;
else
spanMult = (outputMaximum - outputMinimum) / (inputMaximum - inputMinimum);
}
intPower = double(int(normPower));
for (int i = 0; i < inData.Size(); i++)
inData[i] = Normalize(inData[i]);
}
示例8: SetNDX
bool DC_XYData::SetNDX(SC_SetupErr& err,
SC_DoubleArray& ndxData)const
{
int n = 0;
for (int i = 0; i < Size(); i++)
{
double x = xData[i];
double y = yData[i];
if (RealIsNull(x) || RealIsNull(y))
{
err.SetConstantError("all x and y must be non null");
return false;
}
if ((x < 0.5) || (x > 999))
{
err.SetConstantError("all x values must be integers > 0 and < 1000");
return false;
}
if (y < 1.0E-5)
{
err.SetConstantError("all y values must be > 1E-5");
return false;
}
n += int(x);
}
if (n > 10000)
{
err.SetConstantError("total number of x/y ndx calculated nodes points be < 10000");
return false;
}
ndxData.Alloc(n);
for (int i = 0; i < Size(); i++)
{
n = int(xData[i]);
double y = yData[i];
for (int j = 0; j < n; j++)
ndxData += y;
}
return true;
}
示例9: geoLayerZ
void LayerStaticSupport::GetLayerDiscretization(SC_DoubleArray& layerNodeZ,
SC_IntArray& layerWellBoreZoneIndex,
SC_IntArray& layerGeologyIndex)
{
if (!layerSpec.SetThicknesses())
{
layerNodeZ.Alloc(2);
layerNodeZ[0] = 0.0;
layerNodeZ[1] = 1.0;
layerWellBoreZoneIndex.AllocAndFill(1, 0);
layerGeologyIndex.AllocAndFill(1, 0);
return;
}
SC_DoubleArray geoLayerZ(GetNGeoLayer() + 1), geoLayerDZ(GetNGeoLayer());
geoLayerZ[0] = bottomLayerElevation.GetMetricVal();
for (int i = 0; i < GetNGeoLayer(); i++)
{
GeologyLayer& currLayer = geologyLayers[i];
geoLayerZ[i + 1] = geoLayerZ[i] + currLayer.currThickness;
geoLayerDZ[i] = currLayer.currThickness / double(currLayer.nintervalNodes);
}
double maxZ = geoLayerZ.LastIndex();
SC_DoubleArray wbzLayerZ(GetNWellboreZone() + 1);
wbzLayerZ[0] = geoLayerZ[0];
for (int i = 0; i < GetNWellboreZone(); i++)
{
}
}
示例10: CalcMedian
void SC_Statistics::CalcMedian(SC_DoubleArray& data)
{
if (nOK == 0)
return;
if (nOK != data.Size())
{
data.Cleanup();
nOK = data.Size();
}
// mix before sort to help sort routine
SC_Random mix;
mix.RandomMix(data);
if (!data.Sort(true))
{
realResults[soMedian] = nullReal;
}
else
{
int midPt = data.Size() / 2;
if ((data.Size() % 2) == 1)
{
// odd entries -- pick middle
realResults[soMedian] = data[midPt];
}
else
{
// average possibilities
realResults[soMedian] = data[midPt];
realResults[soMedian] += data[midPt - 1];
realResults[soMedian] /= 2.0;
}
}
}
示例11: GetExtraOutput
void SimulatedAnnealingOptimizer::GetExtraOutput(SC_DoubleArray& extraData) const
{
extraData.Alloc(2);
extraData += temperature;
extraData += currSimplexSpan;
}
示例12: productionRestartUnits
namespace nsDataCapture {
DataCaptureArray dataCaptureData;
UnitIndex productionRestartUnits(uTime);
SC_DoubleArray productionRestartTimes;
SC_DoubleMatrix capturedData;
DC_XYDataArray capturedDataXY;
DataCaptureOutput capturedDataFO;
bool dataCaptureUIChange = false;
DataCaptureErrorListing dataCaptureErrorListing;
DataCaptureStaticSupport dataCapture;
CaptureOutputFO::CaptureOutputFO() : FuncObjC("f(t)Output")
{
DataCaptureStaticSupport::capturedObj.AddTo(this);
dcIndex = 0;
AddOutPort(xyDataDO);
AddInPort(xyArrayObjRef, typeid(DO_XYDataArray));
xyArrayObjRef = FuncObjRef(capturedDataFO);
}
CaptureOutputFO::~CaptureOutputFO()
{
DataCaptureStaticSupport::capturedObj.DeleteFrom(this);
}
void CaptureOutputFO::DoStatusChk()
{
xyDataDO.xyData = 0;
FuncObjC::DoStatusChk();
if (!CheckInputFO(xyArrayObjRef, "Input array"))
return;
DO_XYDataArray* dataDO = static_cast<DO_XYDataArray*>(GetInPortData(xyArrayObjRef));
if (dataDO->xyDataArray->IsEmpty())
{
SetObjErrMsg("no entries in input array ??");
return;
}
if (dcIndex > dataDO->xyDataArray->UpperBound())
dcIndex = 0;
xyDataDO.xyData = &(*dataDO->xyDataArray)[dcIndex];
}
void CaptureOutputFO::CalcOutput(FOcalcType calcType)
{
DoStatusChk();
capturedDataFO.InitStaticPressure(); // FB376 fix
}
DataCaptureArray::~DataCaptureArray()
{
// causes memory leak on exit, but required to avoid crash caused
// by capturedObj.DeleteFrom after capturedObj is gone..
tListData = 0;
}
DataCaptureOutput::DataCaptureOutput() :
GlobalFunc("f(t)Table")
{
xyDataArrayDO.xyDataArray = &capturedDataXY;
AddOutPort(xyDataArrayDO);
AddOutPort(staticPressureDO);
staticPressureDO.SetTypeLabel("Static pressure");
staticPressureDO.InitLabelAndValue(0.0);
DoStatusChk();
}
void DataCaptureOutput::DoStatusChk()
{
FuncObjC::DoStatusChk();
if (!xyDataArrayDO.DataOK())
SetObjErrMsg("No data in output table");
}
void DataCaptureOutput::CalcOutput(FOcalcType calcType)
{
DoStatusChk();
if (!StatusOK())
return;
for (int i = 0; i < capturedDataXY.Size(); i++)
capturedDataXY[i].CreateFrom(capturedData[0], capturedData[i + 1]);
}
void DataCaptureOutput::InitStaticPressure()
{
double staticPressure = 0.0;
if (control.IsConfined())
{
Parameter& staticPar = *(allParam[pF_Pf]);
SC_SetupErr dummy;
//.........这里部分代码省略.........
示例13: SetDrawColor
void OGL3DBase::DrawOneAxes( const double& axMin,
const double& axMax,
const SC_DoubleArray& majorIncs,
const SC_DoubleArray& minorIncs,
const PC_AxesFormat& format,
Point2D& stPoint,
Point2D& majTicEndPoint,
Point2D& minTicEndPoint,
Point2D& gridEndPoint,
Point2D& offsetEndPoint,
double& stComponent,
double& majTicComponent,
double& minTicComponent,
double& gridComponent,
double& offsetComponent,
const double& zValue,
Plane3D axPlane,
bool axisIsLog)
{
Point2D* endPoint;
double* endComponent;
PC_3DAxesFormat& axesFormat = plot3Dbase.axesFormat;
DC_PenSet& penSet = *plot3Dbase.defaultPenSet; // default PenSet used for plot
if (format.axesLinePos == PC_AxesFormat::alpBoth)
{
SetDrawColor(penSet.GetColor(axesFormat.axesLinePen));
SetLine(axesFormat.axesLineWidth);
SetLineSolid();
HardCopyBlockStart(6);
stComponent = axMin;
Point2D axSt = stPoint;
stComponent = axMax;
Point2D axEnd = stPoint;
DrawLine(axSt, axEnd, zValue, axPlane);
// needed at axes end to make offsets look clean
endPoint = &offsetEndPoint;
endComponent = &offsetComponent;
stComponent = axMin;
*endComponent = stComponent;
DrawLine(stPoint, *endPoint, zValue, axPlane);
stComponent = axMax;
*endComponent = stComponent;
DrawLine(stPoint, *endPoint, zValue, axPlane);
HardCopyBlockEnd();
}
if ((format.axesMajorInc == PC_Axes::aitGrid) ||
((format.axesMajorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
{
SetDrawColor(penSet.GetColor(axesFormat.majorPen));
if (format.axesMajorInc == PC_Axes::aitTic)
{
SetLine(axesFormat.majorTicWidth);
endPoint = &majTicEndPoint;
endComponent = &majTicComponent;
}
else
{
SetLine(axesFormat.majorGridWidth);
SetLineType(axesFormat.majorGridLineType);
endPoint = &gridEndPoint;
endComponent = &gridComponent;
}
HardCopyBlockStart(majorIncs.Size() * 2);
for (int i = 0; i < majorIncs.Size(); i++)
{
stComponent = majorIncs[i];
if (Limit::WithinOneLimit(axMin, axMax, stComponent))
{
*endComponent = stComponent;
DrawLine(stPoint, *endPoint, zValue, axPlane);
}
}
HardCopyBlockEnd();
}
if ((format.axesMinorInc == PC_Axes::aitGrid) ||
((format.axesMinorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
{
SetDrawColor(penSet.GetColor(axesFormat.minorPen));
if (format.axesMinorInc == PC_Axes::aitTic)
{
SetLine(axesFormat.minorTicWidth);
endPoint = &minTicEndPoint;
endComponent = &minTicComponent;
}
else
{
//.........这里部分代码省略.........
示例14: if
void OGL3DBase::DrawAxesLabels(const SC_DoubleArray& xMajorIncs,
const SC_DoubleArray& xtranMajorIncs,
const SC_DoubleArray& yMajorIncs,
const SC_DoubleArray& ytranMajorIncs,
const SC_DoubleArray& zMajorIncs,
const SC_DoubleArray& ztranMajorIncs,
const SC_RealFormat& xFormat,
const SC_RealFormat& yFormat,
const SC_RealFormat& zFormat)
{
PC_3DAxesLabel& axesLabel = plot3Dbase.axesLabel;
if (!(axesLabel.plotIncrementLabel || axesLabel.plotAxesLabel))
return;
PC_3DAxesFormat& axesFormat = plot3Dbase.axesFormat;
if (axesLabel.autoPositionLabels)
{
axesLabel.xyLabIsVert = (fabs(currView.elevation) < 45.0);
axesLabel.xLabYPosIsMax = (fabs(currView.azimuth) >= 90.0);
axesLabel.yLabXPosIsMax = (currView.azimuth < 0.0);
axesLabel.zLabYPosIsMax = !axesLabel.yLabXPosIsMax;
axesLabel.zLabXPosIsMax = axesLabel.xLabYPosIsMax;
if (fabs(currView.azimuth) >= 135.0)
axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZr;
else if (currView.azimuth < -45.0)
axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZn;
else if (currView.azimuth < 45.0)
axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZn;
else
axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZr;
}
SetDrawColor(plot3Dbase.defaultPenSet->GetColor(axesFormat.majorPen));
double fontRatio = double(axesLabel.incrementFont.fontSize) / double(axesLabel.labelFont.fontSize);
char labStr[80];
Coord3D labLoc;
int i;
bool adjSt, adjEnd;
Coord3D minLim, maxLim;
GetTransformedLimits(minLim, maxLim);
Coord3D offComp = GetPixelComponents(axesFormat.axesOffset);
// x axis first
SetAlignmentAdjust(xtranMajorIncs, minLim.cX, maxLim.cX, adjSt, adjEnd);
labLoc = Coord3D(0.0, minLim.cY - offComp.cY, minLim.cZ - offComp.cZ);
if (axesLabel.xLabYPosIsMax)
labLoc.cY = maxLim.cY + offComp.cY;
double rotVal = 0.0;
if ((!axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax)
rotVal = 180.0;
bool mirror = (axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax;
Plane3D txtPlane = p3D_XY;
if (axesLabel.xyLabIsVert)
txtPlane = p3D_XZ;
HorizontalTextAlignment halign = hta_Center;
if (adjSt)
if (axesLabel.xLabYPosIsMax)
halign = hta_Right;
else
halign = hta_Left;
bool xyExponents = (xFormat.format > ncf_Scientific) || (yFormat.format > ncf_Scientific);
double xyIncOffset = -0.25;
if (xyExponents)
xyIncOffset = -0.40;
if (axesLabel.plotIncrementLabel)
{
for (i = 0; i < xMajorIncs.Size(); i++)
{
labLoc.cX = xtranMajorIncs[i];
if (Limit::WithinOneLimit(minLim.cX, maxLim.cX, labLoc.cX))
{
xFormat.RealToString(xMajorIncs[i], labStr, 80);
if (adjEnd && (i == (xMajorIncs.Size() - 1)))
if (axesLabel.xLabYPosIsMax)
halign = hta_Left;
else
halign = hta_Right;
Axes3DLabel(axesLabel.incrementFont, labLoc,
0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr);
}
halign = hta_Center;
}
}
// need to check both X&Y here
double xyAxOffset = xyIncOffset - 1.15;
if (axesLabel.plotAxesLabel)
{
if (!axesLabel.plotIncrementLabel)
//.........这里部分代码省略.........
示例15: CalcOutput
void PFO_GridContour:: CalcOutput(FOcalcType calcType)
{
DoStatusChk();
if (StatusNotOK())
return;
SC_DoubleArray contourData;
gridData->GetData(contourData);
if (contourSpec.doLogContours)
contourData.Log10();
if (contourData.GetnDataOK() < 3)
{
SetObjErrMsg("less than 3 valid data");
return;
}
SC_Triangulation& currTri = gridData->GetTriangulation();
contourLines.Alloc(contourSpec.Size());
SC_IntArray orderedPoints;
Line3D cLine;
Coord3D nextPoint;
for (int i = 0; i < contourSpec.Size(); i++)
{
double currVal = contourSpec[i].contourVal;
if (contourSpec.doLogContours)
currVal = log10(currVal);
if (currTri.GetConnectedEdgeList(contourData, currVal, orderedPoints))
{
contourLines[i].Alloc(orderedPoints.Size());
for (int j = 0; j < orderedPoints.Size(); j++)
{
int edgeIndex = orderedPoints[j];
if (edgeIndex < 0)
{
nextPoint = Coord3D();
}
else
{
const SC_Triangulation::TriangleEdge& currEdge = currTri.GetEdge(edgeIndex);
currTri.GetNodeCoord(currEdge.stNode, cLine.stPt);
currTri.GetNodeCoord(currEdge.endNode, cLine.endPt);
// slight kluge: if Z is same, honor log stuff
if ((zvalueSource == zvs_Same) && contourSpec.doLogContours)
{
cLine.stPt.cZ = contourData[currEdge.stNode];
cLine.endPt.cZ = contourData[currEdge.endNode];
nextPoint = cLine.PointOnLine(currEdge.cPos);
nextPoint.cZ = InvLgt(nextPoint.cZ);
}
else
{
cLine.stPt.cZ = GetZVal(currEdge.stNode, *gridData);
cLine.endPt.cZ = GetZVal(currEdge.endNode, *gridData);
nextPoint = cLine.PointOnLine(currEdge.cPos);
}
// just affects X & Y
gridData->UnTransformCoord(nextPoint);
MapCoords(nextPoint);
}
contourLines[i] += nextPoint;
}
}
}
contourLines.SetSize(contourSpec.Size());
}