<commit_before>/*
 * Copyright (C) 2009 <NAME>
 * Copyright (C) 2010-2011 <NAME>
 *
 * JPOWER is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * JPOWER is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JPOWER. If not, see <http://www.gnu.org/licenses/>.
 *
 */

package be.kuleuven.esat.electa.jdyn.tdouble;

import cern.colt.matrix.tdcomplex.DComplexFactory1D;
import cern.colt.matrix.tdcomplex.DComplexMatrix1D;
import cern.colt.matrix.tdcomplex.algo.decomposition.SparseDComplexLUDecomposition;
import cern.colt.matrix.tdouble.DoubleMatrix1D;
import cern.colt.matrix.tdouble.DoubleMatrix2D;
import cern.colt.matrix.tint.IntFactory1D;
import cern.colt.matrix.tint.IntMatrix1D;
import cern.colt.util.tdouble.Djp_util;
import cern.jet.math.tdcomplex.DComplexFunctions;
import cern.jet.math.tint.IntFunctions;

/**
 * Solves the network.
 *
 * @author <NAME>
 * @author <NAME>
 *
 */
public class Djd_SolveNetwork {

	private static final IntFunctions ifunc = IntFunctions.intFunctions;
	private static final DComplexFunctions cfunc = DComplexFunctions.functions;

	/**
	 *
	 * @param Xgen state variables of generators
	 * @param Pgen parameters of generators
	 * @param invYbus factorised augmented bus admittance matrix
	 * @param gbus generator buses
	 * @param gentype generator models
	 * @return bus voltages
	 */
	@SuppressWarnings("static-access")
	public static DComplexMatrix1D jp_SolveNetwork(DoubleMatrix2D Xgen, DoubleMatrix2D Pgen,
			SparseDComplexLUDecomposition invYbus, int[] gbus, IntMatrix1D gentype) {

		int ngen, s;
		int[] type1, type2;
		IntMatrix1D d;
		DoubleMatrix1D delta, Eq_tr, Ed_tr, xd_tr;
		DComplexMatrix1D Igen, Ig, U;

		/* Init */
		ngen = gbus.length;
		Igen = DComplexFactory1D.dense.make(ngen);

		s = invYbus.getPivot().length;

		Ig = DComplexFactory1D.dense.make(s);
		d = IntFactory1D.dense.make(Djp_util.irange((int) gentype.size()));

		/* Define types */
		type1 = d.viewSelection( gentype.copy().assign(ifunc.equals(1)).toArray() ).toArray();
		type2 = d.viewSelection( gentype.copy().assign(ifunc.equals(2)).toArray() ).toArray();<commit_msg>Minor fix of static members.<commit_after>/*
 * Copyright (C) 2009 <NAME>
 * Copyright (C) 2010-2011 <NAME>
 *
 * JPOWER is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * JPOWER is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JPOWER. If not, see <http://www.gnu.org/licenses/>.
 *
 */

package be.kuleuven.esat.electa.jdyn.tdouble;

import cern.colt.matrix.tdcomplex.DComplexFactory1D;
import cern.colt.matrix.tdcomplex.DComplexMatrix1D;
import cern.colt.matrix.tdcomplex.algo.decomposition.SparseDComplexLUDecomposition;
import cern.colt.matrix.tdouble.DoubleMatrix1D;
import cern.colt.matrix.tdouble.DoubleMatrix2D;
import cern.colt.matrix.tint.IntFactory1D;
import cern.colt.matrix.tint.IntMatrix1D;
import cern.colt.util.tdouble.Djp_util;
import cern.jet.math.tdcomplex.DComplexFunctions;
import cern.jet.math.tint.IntFunctions;

/**
 * Solves the network.
 *
 * @author <NAME>
 * @author <NAME>
 *
 */
public class Djd_SolveNetwork {

	private static final IntFunctions ifunc = IntFunctions.intFunctions;
	private static final DComplexFunctions cfunc = DComplexFunctions.functions;

	private static int ngen, s;
	private static int[] type1, type2;
	private static IntMatrix1D d;
	private static DoubleMatrix1D delta, Eq_tr, Ed_tr, xd_tr;
	private static DComplexMatrix1D Igen, Ig, U;

	/**
	 *
	 * @param Xgen state variables of generators
	 * @param Pgen parameters of generators
	 * @param invYbus factorised augmented bus admittance matrix
	 * @param gbus generator buses
	 * @param gentype generator models
	 * @return bus voltages
	 */
	@SuppressWarnings("static-access")
	public static DComplexMatrix1D jp_SolveNetwork(DoubleMatrix2D Xgen, DoubleMatrix2D Pgen,
			SparseDComplexLUDecomposition invYbus, int[] gbus, IntMatrix1D gentype) {

		/* Init */
		ngen = gbus.length;
		Igen = DComplexFactory1D.dense.make(ngen);

		s = invYbus.getPivot().length;

		Ig = DComplexFactory1D.dense.make(s);
		d = IntFactory1D.dense.make(Djp_util.irange((int) gentype.size()));

		/* Define types */
		type1 = d.viewSelection( gentype.copy().assign(ifunc.equals(1)).toArray() ).toArray();
		type2 = d.viewSelection( gentype.copy().assign(ifunc.equals(2)).toArray() ).toArray();
{'fraction_non_alphanumeric': 0.10326191854854275, 'fraction_numerical': 0.013510905230650454, 'mean_word_length': 4.566058002148227, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5450526', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1645, 'n_words': 475}