本文整理汇总了C#中Altaxo.Data.DataTable类的典型用法代码示例。如果您正苦于以下问题:C# DataTable类的具体用法?C# DataTable怎么用?C# DataTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataTable类属于Altaxo.Data命名空间,在下文中一共展示了DataTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreatePlotItems
public static List<IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G3DPlotStyleCollection templatePlotStyle)
{
var selColumns = new List<DataColumn>(selectedColumns.Count);
foreach (int i in selectedColumns)
selColumns.Add(table[i]);
return CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext());
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:PlotCommands3D.cs
示例2: GetCalibrationModel
public override IMultivariateCalibrationModel GetCalibrationModel(
DataTable calibTable)
{
PLS2CalibrationModel model;
Export(calibTable, out model);
return model;
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:PLS2WorksheetAnalysis.cs
示例3: SetContentFromMatrix
public static void SetContentFromMatrix(DataTable destinationTable, IROMatrix matrix, string columnBaseName, IROVector rowHeaderColumn, string rowHeaderColumnName, IROVector colHeaderColumn, string colHeaderColumnName)
{
var c = new MatrixToDataTableConverter(matrix, destinationTable);
c.ColumnBaseName = columnBaseName;
c.AddMatrixColumnHeaderData(rowHeaderColumn, rowHeaderColumnName);
c.AddMatrixColumnHeaderData(colHeaderColumn, colHeaderColumnName);
c.Execute();
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:MatrixToDataTableConverter.cs
示例4: Import
public override void Import(
IMultivariateCalibrationModel calibrationSet,
DataTable table)
{
PCRCalibrationModel calib = (PCRCalibrationModel)calibrationSet;
int numFactors = calib.NumberOfFactors;
int numberOfY = calib.NumberOfY;
int numberOfPoints = calib.XLoads.Rows;
// store the x-loads - careful - they are horizontal
for(int i=0;i<numFactors;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.XLoads.Columns;j++)
col[j] = calib.XLoads[i,j];
table.DataColumns.Add(col,GetXLoad_ColumnName(i),Altaxo.Data.ColumnKind.V,0);
}
// now store the scores - careful - they are vertical in the matrix
for(int i=0;i<numFactors;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.XScores.Rows;j++)
col[j] = calib.XScores[j,i];
table.DataColumns.Add(col,GetXScore_ColumnName(i),Altaxo.Data.ColumnKind.V,0);
}
// now store the y-loads (this are the preprocessed y in this case
for(int cn=0;cn<numberOfY;cn++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int i=0;i<numberOfPoints;i++)
col[i] = calib.YLoads[i,cn];
table.DataColumns.Add(col,GetYLoad_ColumnName(cn),Altaxo.Data.ColumnKind.V,0);
}
// now store the cross product vector - it is a horizontal vector
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<numFactors;j++)
col[j] = calib.CrossProduct[j];
table.DataColumns.Add(col,GetCrossProduct_ColumnName(),Altaxo.Data.ColumnKind.V,3);
}
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:58,代码来源:PCRWorksheetAnalysis.cs
示例5: TableNode
public TableNode(DataTable table)
: base(true)
{
_collection = table.DataColumns;
_firstColumn = 0;
_columnCount = table.DataColumns.ColumnCount;
Text = table.ShortName;
Tag = table;
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:9,代码来源:SingleColumnChoiceController.cs
示例6: Import
public override void Import(
IMultivariateCalibrationModel calibrationSet,
DataTable table)
{
PLS1CalibrationModel calib = (PLS1CalibrationModel)calibrationSet;
for(int yn=0;yn<calib.NumberOfY;yn++)
{
// store the x-loads - careful - they are horizontal in the matrix
for(int i=0;i<calib.XLoads[yn].Rows;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.XLoads[yn].Columns;j++)
col[j] = calib.XLoads[yn][i,j];
table.DataColumns.Add(col,GetXLoad_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,0);
}
// now store the y-loads - careful - they are horizontal in the matrix
for(int i=0;i<calib.YLoads[yn].Rows;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.YLoads[yn].Columns;j++)
col[j] = calib.YLoads[yn][i,j];
table.DataColumns.Add(col,GetYLoad_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,1);
}
// now store the weights - careful - they are horizontal in the matrix
for(int i=0;i<calib.XWeights[yn].Rows;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.XWeights[yn].Columns;j++)
col[j] = calib.XWeights[yn][i,j];
table.DataColumns.Add(col,GetXWeight_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,0);
}
// now store the cross product vector - it is a horizontal vector
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<calib.CrossProduct[yn].Columns;j++)
col[j] = calib.CrossProduct[yn][0,j];
table.DataColumns.Add(col,GetCrossProduct_ColumnName(yn),Altaxo.Data.ColumnKind.V,3);
}
} // for all y (constituents)
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:56,代码来源:PLS1WorksheetAnalysis.cs
示例7: MatrixToDataTableConverter
public MatrixToDataTableConverter(IROMatrix sourceMatrix, DataTable destinationTable)
{
if (null == sourceMatrix)
throw new ArgumentNullException("sourceMatrix");
if (null == destinationTable)
throw new ArgumentNullException("destinationTable");
_sourceMatrix = sourceMatrix;
_destinationTable = destinationTable;
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:10,代码来源:MatrixToDataTableConverter.cs
示例8: ShowRealFourierTransformation2DDialog
/// <summary>
/// Shows the dialog in which the user can select options for the 2D Fourier transformation, and then executes the Fourier transformation
/// The result is stored in a newly created data table in the same folder as the source data table.
/// </summary>
/// <param name="table">The table containing the data to transform.</param>
/// <param name="selectedDataRows">The selected data rows of the table. (A value of <c>null</c> can be provided here).</param>
/// <param name="selectedDataColumns">The selected data columns of the table. (A value of <c>null</c> can be provided here).</param>
/// <param name="selectedPropertyColumns">The selected property columns of the table. (A value of <c>null</c> can be provided here).</param>
public static void ShowRealFourierTransformation2DDialog(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
{
DataTableMatrixProxy proxy = null;
RealFourierTransformation2DOptions options = null;
try
{
proxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns);
options = null != _lastUsedOptions ? (RealFourierTransformation2DOptions)_lastUsedOptions.Clone() : new RealFourierTransformation2DOptions();
double rowIncrementValue; string rowIncrementMessage;
proxy.TryGetRowHeaderIncrement(out rowIncrementValue, out rowIncrementMessage);
double columnIncrementValue; string columnIncrementMessage;
proxy.TryGetColumnHeaderIncrement(out columnIncrementValue, out columnIncrementMessage);
options.IsUserDefinedRowIncrementValue = false;
options.RowIncrementValue = rowIncrementValue;
options.RowIncrementMessage = rowIncrementMessage;
options.IsUserDefinedColumnIncrementValue = false;
options.ColumnIncrementValue = columnIncrementValue;
options.ColumnIncrementMessage = columnIncrementMessage;
}
catch (Exception ex)
{
Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in preparation of Fourier transformation");
return;
}
if (!Current.Gui.ShowDialog(ref options, "Choose fourier transform options", false))
return;
_lastUsedOptions = options;
try
{
var resultTable = new DataTable { Name = string.Format("{0}Fourier{1} of {2}", table.Folder, options.OutputKind, table.ShortName) };
ExecuteFouriertransformation2D(proxy, options, resultTable);
// Create a DataSource
Altaxo.Worksheet.Commands.Analysis.FourierTransformation2DDataSource dataSource = new FourierTransformation2DDataSource(proxy, options, new Altaxo.Data.DataSourceImportOptions());
resultTable.DataSource = dataSource;
Current.ProjectService.OpenOrCreateWorksheetForTable(resultTable);
}
catch (Exception ex)
{
Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in execution of Fourier transformation");
return;
}
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:60,代码来源:FourierCommands.cs
示例9: ToDataTable
/// <summary>
/// Imports a Jcamp file into an DataTable. The file must not be a multi spectrum file (an exception is thrown in this case).
/// </summary>
/// <param name="table">On return, contains the newly created data table with the spectral data.</param>
/// <param name="stream">The stream where to import from.</param>
/// <returns>Null if successful, otherwise an error description.</returns>
public static string ToDataTable(System.IO.Stream stream, out DataTable table)
{
table = null;
TextReader tr;
try
{
tr = new StreamReader(stream);
return ToDataTable(tr, out table);
}
catch (Exception ex)
{
return ex.Message;
}
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:20,代码来源:ImportJcampFiles.cs
示例10: SDTableScriptController
public SDTableScriptController(Altaxo.Data.DataTable dataTable, TableScript tableScript)
{
this.m_DataTable = dataTable;
if(null!=tableScript)
{
this.m_TableScript = (IScriptText)tableScript.Clone();
}
else
{
this.m_TableScript = new TableScript();
}
SetElements(true);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:16,代码来源:SDTableScriptController.cs
示例11: MergeTable
/// <summary>
/// Merges two tables by fractional index.
/// </summary>
/// <param name="destinationTable">Table to merge into.</param>
/// <param name="fractionalIndex">Array of fractional indices. Each item points into the slaveTable to the value that should be included in the master column at the item's index.</param>
/// <param name="slaveTable">The table providing the data for merging into the master table.</param>
/// <param name="slaveColumnsToMerge">Indices of that columns of the slave table that should be merged into the master table.</param>
public static void MergeTable(
this DataTable destinationTable,
DoubleColumn fractionalIndex,
DataTable slaveTable,
IAscendingIntegerCollection slaveColumnsToMerge)
{
int destinationTableStartIdx = destinationTable.DataColumnCount;
destinationTable.AddDataColumnsWithPropertiesFrom(slaveTable, slaveColumnsToMerge);
for (int i = 0; i < slaveColumnsToMerge.Count; i++)
{
int slaveColIdx = slaveColumnsToMerge[i];
DataColumn newCol = destinationTable[destinationTableStartIdx + i];
SetColumnFromFractionalIndex(newCol, fractionalIndex, slaveTable[slaveColIdx]);
}
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:24,代码来源:MergeTables.cs
示例12: GetCommonDataTableAndGroupNumberFromColumns
/// <summary>
/// Try to get a common data table and a group number from all columns (here we don't rely on <see cref="DataTable"/> and GroupNumber of this document).
/// </summary>
/// <param name="columns">The columns to consider. <see cref="ITransformedReadableColumn"/> will be stripped to get the underlying data column.</param>
/// <param name="dataTableIsNotUniform">If the columns gives different result for their underlying data table, the result here will be true.</param>
/// <param name="commonDataTable">If the previous parameter results in false, this is the common data table of all columns. If the previous parameter is true, this is the first underlying data table that could be deduced from the columns. The result is null if no underlying table could be deduced from the columns.</param>
/// <param name="groupNumberIsNotUniform">If the columns gives different result for their group number, the result here will be true.</param>
/// <param name="commonGroupNumber">If the previous parameter results in false, this is the common group number of all columns. If the previous parameter results in true, this is the first group number that could be deduced from the columns. The result is null if no group number could be deduced from the columns.</param>
public static void GetCommonDataTableAndGroupNumberFromColumns(this IEnumerable<IReadableColumn> columns, out bool dataTableIsNotUniform, out DataTable commonDataTable, out bool groupNumberIsNotUniform, out int? commonGroupNumber)
{
dataTableIsNotUniform = false;
groupNumberIsNotUniform = false;
commonDataTable = null;
commonGroupNumber = null;
foreach(var col in columns)
{
IReadableColumn underlyingColumn = col;
while (underlyingColumn is ITransformedReadableColumn)
{
underlyingColumn = (underlyingColumn as ITransformedReadableColumn).UnderlyingReadableColumn;
}
if (underlyingColumn is DataColumn)
{
var colColl = DataColumnCollection.GetParentDataColumnCollectionOf((DataColumn)underlyingColumn);
var dataTable = DataTable.GetParentDataTableOf(colColl);
int? groupNumber = colColl?.GetColumnGroup((DataColumn)underlyingColumn);
if (null != dataTable)
{
if (null == commonDataTable)
commonDataTable = dataTable;
else if (!object.ReferenceEquals(commonDataTable, dataTable))
dataTableIsNotUniform = true;
}
if (null != groupNumber)
{
if (null == commonGroupNumber)
commonGroupNumber = groupNumber;
else if (!(commonGroupNumber == groupNumber))
groupNumberIsNotUniform = true;
}
}
}
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:48,代码来源:IReadableColumnExtensions.cs
示例13: Import
/// <summary>
/// Imports a Origin OPJ file (tables only) into corresponding new tables in Altaxo.
/// </summary>
/// <param name="filename">The file name of the origin OPJ file.</param>
/// <returns>Null if the import was successfull, or a error message.</returns>
public static string Import(string filename)
{
OpjFile opj = new OpjFile(filename);
opj.Parse();
// now create corresponding tables in Altaxo
for (int nspread = 0; nspread < opj.numSpreads(); nspread++)
{
// Create a new table
string tablename = Current.Project.DataTableCollection.FindNewTableName(opj.spreadName(nspread));
DataTable table = new DataTable(tablename);
int numberOfColumns = opj.numCols(nspread);
for (int ncol = 0; ncol < numberOfColumns; ncol++)
{
string colname = opj.colName(nspread, ncol);
string coltype = opj.colType(nspread, ncol);
int numberOfRows = opj.numRows(nspread, ncol);
ColumnKind kind = coltype == "X" ? ColumnKind.X : ColumnKind.V;
DoubleColumn column = new DoubleColumn(numberOfRows);
column.CopyDataFrom(opj.Data(nspread, ncol), numberOfRows);
colname = table.DataColumns.FindUniqueColumnName(colname);
table.DataColumns.Add(column, colname, kind, 0);
}
table.Name = tablename;
Current.Project.DataTableCollection.Add(table);
Current.ProjectService.CreateNewWorksheet(table);
}
return null;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:41,代码来源:Import.cs
示例14: PlotPreprocessedSpectra
/// <summary>
/// Plots all preprocessed spectra into a newly created graph.
/// </summary>
/// <param name="table">The table of PLS output data.</param>
public static void PlotPreprocessedSpectra(Altaxo.Data.DataTable table)
{
DataTable desttable = new DataTable();
desttable.Name = table.Name+".PS";
GetAnalysis(table).CalculatePreprocessedSpectra(table, desttable);
Current.Project.DataTableCollection.Add(desttable);
Worksheet.Commands.PlotCommands.PlotLine(desttable,new IntegerRangeAsCollection(1,desttable.DataColumnCount-1),true,false);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:13,代码来源:ChemometricCommands.cs
示例15: GetAnalysis
public static WorksheetAnalysis GetAnalysis(DataTable table)
{
MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;
if(plsMemo==null)
throw new ArgumentException("Table does not contain a PLSContentMemento");
return plsMemo.Analysis;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:ChemometricCommands.cs
示例16: MultiplyColumnsToMatrix
/// <summary>
/// Multiplies selected columns to form a matrix.
/// </summary>
/// <param name="mainDocument"></param>
/// <param name="srctable"></param>
/// <param name="selectedColumns"></param>
/// <returns>Null if successful, else the description of the error.</returns>
/// <remarks>The user must select an even number of columns. All columns of the first half of the selection
/// must have the same number of rows, and all columns of the second half of selection must also have the same
/// number of rows. The first half of selected columns form a matrix of dimensions(firstrowcount,halfselected), and the second half
/// of selected columns form a matrix of dimension(halfselected, secondrowcount). The resulting matrix has dimensions (firstrowcount,secondrowcount) and is
/// stored in a separate worksheet.</remarks>
public static string MultiplyColumnsToMatrix(
Altaxo.AltaxoDocument mainDocument,
Altaxo.Data.DataTable srctable,
IAscendingIntegerCollection selectedColumns
)
{
// check that there are columns selected
if(0==selectedColumns.Count)
return "You must select at least two columns to multiply!";
// selected columns must contain an even number of columns
if(0!=selectedColumns.Count%2)
return "You selected an odd number of columns. Please select an even number of columns to multiply!";
// all selected columns must be numeric columns
for(int i=0;i<selectedColumns.Count;i++)
{
if(!(srctable[selectedColumns[i]] is Altaxo.Data.INumericColumn))
return string.Format("The column[{0}] (name:{1}) is not a numeric column!",selectedColumns[i],srctable[selectedColumns[i]].Name);
}
int halfselect = selectedColumns.Count/2;
// check that all columns from the first half of selected colums contain the same
// number of rows
int rowsfirsthalf=int.MinValue;
for(int i=0;i<halfselect;i++)
{
int idx = selectedColumns[i];
if(rowsfirsthalf<0)
rowsfirsthalf = srctable[idx].Count;
else if(rowsfirsthalf != srctable[idx].Count)
return "The first half of selected columns have not all the same length!";
}
int rowssecondhalf=int.MinValue;
for(int i=halfselect;i<selectedColumns.Count;i++)
{
int idx = selectedColumns[i];
if(rowssecondhalf<0)
rowssecondhalf = srctable[idx].Count;
else if(rowssecondhalf != srctable[idx].Count)
return "The second half of selected columns have not all the same length!";
}
// now create the matrices to multiply from the
MatrixMath.REMatrix firstMat = new MatrixMath.REMatrix(rowsfirsthalf,halfselect);
for(int i=0;i<halfselect;i++)
{
Altaxo.Data.INumericColumn col = (Altaxo.Data.INumericColumn)srctable[selectedColumns[i]];
for(int j=0;j<rowsfirsthalf;j++)
firstMat[j,i] = col[j];
}
MatrixMath.BEMatrix secondMat = new MatrixMath.BEMatrix(halfselect,rowssecondhalf);
for(int i=0;i<halfselect;i++)
{
Altaxo.Data.INumericColumn col = (Altaxo.Data.INumericColumn)srctable[selectedColumns[i+halfselect]];
for(int j=0;j<rowssecondhalf;j++)
secondMat[i,j] = col[j];
}
// now multiply the two matrices
MatrixMath.BEMatrix resultMat = new MatrixMath.BEMatrix(rowsfirsthalf,rowssecondhalf);
MatrixMath.Multiply(firstMat,secondMat,resultMat);
// and store the result in a new worksheet
Altaxo.Data.DataTable table = new Altaxo.Data.DataTable("ResultMatrix of " + srctable.Name);
table.Suspend();
// first store the factors
for(int i=0;i<resultMat.Columns;i++)
{
Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
for(int j=0;j<resultMat.Rows;j++)
col[j] = resultMat[j,i];
table.DataColumns.Add(col,i.ToString());
}
table.Resume();
mainDocument.DataTableCollection.Add(table);
// create a new worksheet without any columns
Current.ProjectService.CreateNewWorksheet(table);
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:ChemometricCommands.cs
示例17: PrincipalComponentAnalysis
/// <summary>
/// Makes a PCA (a principal component analysis) of the table or the selected columns / rows and stores the results in a newly created table.
/// </summary>
/// <param name="mainDocument">The main document of the application.</param>
/// <param name="srctable">The table where the data come from.</param>
/// <param name="selectedColumns">The selected columns.</param>
/// <param name="selectedRows">The selected rows.</param>
/// <param name="bHorizontalOrientedSpectrum">True if a spectrum is a single row, False if a spectrum is a single column.</param>
/// <param name="maxNumberOfFactors">The maximum number of factors to calculate.</param>
/// <returns></returns>
public static string PrincipalComponentAnalysis(
Altaxo.AltaxoDocument mainDocument,
Altaxo.Data.DataTable srctable,
IAscendingIntegerCollection selectedColumns,
IAscendingIntegerCollection selectedRows,
bool bHorizontalOrientedSpectrum,
int maxNumberOfFactors
)
{
bool bUseSelectedColumns = (null!=selectedColumns && 0!=selectedColumns.Count);
int prenumcols = bUseSelectedColumns ? selectedColumns.Count : srctable.DataColumns.ColumnCount;
// check for the number of numeric columns
int numcols = 0;
for(int i=0;i<prenumcols;i++)
{
int idx = bUseSelectedColumns ? selectedColumns[i] : i;
if(srctable[i] is Altaxo.Data.INumericColumn)
numcols++;
}
// check the number of rows
bool bUseSelectedRows = (null!=selectedRows && 0!=selectedRows.Count);
int numrows;
if(bUseSelectedRows)
numrows = selectedRows.Count;
else
{
numrows = 0;
for(int i=0;i<numcols;i++)
{
int idx = bUseSelectedColumns ? selectedColumns[i] : i;
numrows = Math.Max(numrows,srctable[idx].Count);
}
}
// check that both dimensions are at least 2 - otherwise PCA is not possible
if(numrows<2)
return "At least two rows are neccessary to do Principal Component Analysis!";
if(numcols<2)
return "At least two numeric columns are neccessary to do Principal Component Analysis!";
// Create a matrix of appropriate dimensions and fill it
MatrixMath.BEMatrix matrixX;
if(bHorizontalOrientedSpectrum)
{
matrixX = new MatrixMath.BEMatrix(numrows,numcols);
int ccol = 0; // current column in the matrix
for(int i=0;i<prenumcols;i++)
{
int colidx = bUseSelectedColumns ? selectedColumns[i] : i;
Altaxo.Data.INumericColumn col = srctable[colidx] as Altaxo.Data.INumericColumn;
if(null!=col)
{
for(int j=0;j<numrows;j++)
{
int rowidx = bUseSelectedRows ? selectedRows[j] : j;
matrixX[j,ccol] = col[rowidx];
}
++ccol;
}
}
} // end if it was a horizontal oriented spectrum
else // if it is a vertical oriented spectrum
{
matrixX = new MatrixMath.BEMatrix(numcols,numrows);
int ccol = 0; // current column in the matrix
for(int i=0;i<prenumcols;i++)
{
int colidx = bUseSelectedColumns ? selectedColumns[i] : i;
Altaxo.Data.INumericColumn col = srctable[colidx] as Altaxo.Data.INumericColumn;
if(null!=col)
{
for(int j=0;j<numrows;j++)
{
int rowidx = bUseSelectedRows ? selectedRows[j] : j;
matrixX[ccol,j] = col[rowidx];
}
++ccol;
}
}
} // if it was a vertical oriented spectrum
// now do PCA with the matrix
MatrixMath.REMatrix factors = new MatrixMath.REMatrix(0,0);
MatrixMath.BEMatrix loads = new MatrixMath.BEMatrix(0,0);
MatrixMath.BEMatrix residualVariances = new MatrixMath.BEMatrix(0,0);
MatrixMath.HorizontalVector meanX = new MatrixMath.HorizontalVector(matrixX.Columns);
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:ChemometricCommands.cs
示例18: CalculatePredictionScores
/// <summary>
/// Calculates the prediction scores. In case of a single y-variable, the prediction score is a vector of the same length than a spectrum.
/// Multiplying the prediction score (dot product) with a spectrum, it yields the predicted y-value (of cause mean-centered).
/// </summary>
/// <param name="table">The table where the calibration model is stored.</param>
/// <param name="preferredNumberOfFactors">Number of factors used to calculate the prediction scores.</param>
/// <returns>A matrix with the prediction scores. Each score (for one y-value) is a row in the matrix.</returns>
public virtual IROMatrix CalculatePredictionScores(DataTable table, int preferredNumberOfFactors)
{
MultivariateRegression regress = this.CreateNewRegressionObject();
IMultivariateCalibrationModel model = this.GetCalibrationModel(table);
regress.SetCalibrationModel(model);
return regress.GetPredictionScores(preferredNumberOfFactors);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:14,代码来源:WorksheetAnalysis.cs
示例19: RealFourierTransform
public static void RealFourierTransform(RealFourierTransformOptions options)
{
var yCol = options.ColumnToTransform;
int fftLen = yCol.Count;
double[] resultCol = new double[fftLen];
for (int i = 0; i < resultCol.Length; ++i)
resultCol[i] = yCol[i];
var transform = new Calc.Fourier.RealFourierTransform(fftLen);
transform.Transform(resultCol, Calc.Fourier.FourierDirection.Forward);
var wrapper = new Calc.Fourier.RealFFTResultWrapper(resultCol);
DataTable outputTable = null;
switch (options.OutputPlacement)
{
case RealFourierTransformOutputPlacement.CreateInNewWorksheet:
outputTable = new DataTable();
outputTable.Name = "Real FFT results";
Current.Project.DataTableCollection.Add(outputTable);
Current.ProjectService.OpenOrCreateWorksheetForTable(outputTable);
break;
case RealFourierTransformOutputPlacement.CreateInSameWorksheet:
outputTable = DataTable.GetParentDataTableOf(yCol);
if (null == outputTable)
throw new ArgumentException("Provided y-column does not belong to a data table.");
break;
default:
throw new ArgumentOutOfRangeException("Unkown enum value: " + options.OutputPlacement.ToString());
}
// create the x-Column first
var freqCol = new DoubleColumn();
freqCol.AssignVector = wrapper.FrequenciesFromXIncrement(options.XIncrementValue);
int outputGroup = outputTable.DataColumns.GetUnusedColumnGroupNumber();
outputTable.DataColumns.Add(freqCol, "Frequency", ColumnKind.X, outputGroup);
// now create the other output cols
if (options.Output.HasFlag(RealFourierTransformOutput.Re))
{
var col = new DoubleColumn();
col.AssignVector = wrapper.RealPart;
outputTable.DataColumns.Add(col, "Re", ColumnKind.V, outputGroup);
}
if (options.Output.HasFlag(RealFourierTransformOutput.Im))
{
var col = new DoubleColumn();
col.AssignVector = wrapper.ImaginaryPart;
outputTable.DataColumns.Add(col, "Im", ColumnKind.V, outputGroup);
}
if (options.Output.HasFlag(RealFourierTransformOutput.Abs))
{
var col = new DoubleColumn();
col.AssignVector = wrapper.Amplitude;
outputTable.DataColumns.Add(col, "Abs", ColumnKind.V, outputGroup);
}
if (options.Output.HasFlag(RealFourierTransformOutput.Phase))
{
var col = new DoubleColumn();
col.AssignVector = wrapper.Phase;
outputTable.DataColumns.Add(col, "Phase", ColumnKind.V, outputGroup);
}
if (options.Output.HasFlag(RealFourierTransformOutput.Power))
{
var col = new DoubleColumn();
col.AssignVector = wrapper.Amplitude;
col.Data = col * col;
outputTable.DataColumns.Add(col, "Power", ColumnKind.V, outputGroup);
}
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:77,代码来源:AnalysisRealFourierTransformCommands.cs
示例20: AddStatisticColumns
private static void AddStatisticColumns(DataTable result)
{
result.DataColumns.Add(new DoubleColumn(), DefaultMeanColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultStandardErrorColumnName, ColumnKind.Err, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultStandardDeviationColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultSumColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultSumSqrColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultNumberOfItemsColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultFractionInOneSigmaColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultFractionInTwoSigmaColumnName, ColumnKind.V, 0);
result.DataColumns.Add(new DoubleColumn(), DefaultFractionInThreeSigmaColumnName, ColumnKind.V, 0);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:12,代码来源:StatisticCommands.cs
注:本文中的Altaxo.Data.DataTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论