Analysis.PLS.MainForm.btnProject_Click C# (CSharp) Method

btnProject_Click() private method

private btnProject_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void btnProject_Click(object sender, EventArgs e)
        {
            if (pls == null || dgvProjectionSourceX.DataSource == null || dgvProjectionSourceY.DataSource == null)
            {
                MessageBox.Show("Please compute the analysis first.");
                return;
            }

            int components = (int)numComponents.Value;
            double[,] sourceInput = Matrix.ToMatrix(dgvProjectionSourceX.DataSource as DataTable);
            double[,] sourceOutput = Matrix.ToMatrix(dgvProjectionSourceY.DataSource as DataTable);

            double[,] input = pls.Transform(sourceInput, components);
            double[,] output = pls.TransformOutput(sourceOutput, components);

            dgvProjectionX.DataSource = new ArrayDataView(input);
            dgvProjectionY.DataSource = new ArrayDataView(output);
        }