Esempio n. 1
0
void NRSOLUTION::InitPFlow()
{
	FreeArray(RightP); FreeArray(RightQ);

	MAXITER = 100; MAXPERR = MAXQERR = 0.005f;
	IsInit = pNet->m_ChangeCode;

	NRSBusTotal = pNet->iGetBusTotal();
	Volt = pNet->BusVolt; Sita = pNet->BusSita;
	MallocNew(RightP, real, NRSBusTotal);
	MallocNew(RightQ, real, NRSBusTotal);
	m_Solver->InitMatrix(pNet->m_Matrix);
}
Esempio n. 2
0
static void
create_subnet(Subnet *parent_subnet, int the_entry)
{
  parent_subnet->entry[the_entry] = (void *) MallocNew(Subnet);
  clear_subnet((Subnet *) parent_subnet->entry[the_entry]);
  alloced += sizeof (Subnet);
  check_alloc_limit();
}
int COMPLEXSPAREMATRIXSOLVER::MatrixVectorMultiply(real *tX, real *tY)
{
	real *tempX = NULL, *tempY = NULL;
	MallocNew(tempX, real, RowTotal); memcpy(tempX, tX, RowTotal*sizeof(real));
	MallocNew(tempY, real, RowTotal); memcpy(tempY, tY, RowTotal*sizeof(real));
	memset(tX, 0, RowTotal*sizeof(real));
	memset(tY, 0, RowTotal*sizeof(real));
	int i, j, k, jCol;
	for (i = 0; i<RowTotal; i++)
	{
		for (j = 0, k = pMatrix->IA[i]; j<pMatrix->NA[i]; j++, k++)
		{
			jCol = pMatrix->JA[k];
			tX[i] += VA[k].RowH*tempX[jCol] + VA[k].RowN*tempY[jCol];
			tY[i] += VA[k].RowJ*tempX[jCol] + VA[k].RowL*tempY[jCol];
		}
	}
	return 1;
}
void COMPLEXSPAREMATRIXSOLVER::InitMatrix(COMPLEXSPAREMATRIX *tMatrix)
{
	pMatrix = tMatrix;
	RowTotal = pMatrix->RowTotal;
	ElementTotal = pMatrix->ElementTotal;
	MallocNew(VA, Composite, ElementTotal);
	if (pMatrix->IsNewNo == 0)
	{
		pMatrix->SpareMatrixReorder();
	}
	//pMatrix->ReSetOldOrder();
	NewNo = pMatrix->NewNo;
	OldNo = pMatrix->OldNo;
	NIA = pMatrix->NIA;
	NNA = pMatrix->NNA;
	NJA = pMatrix->NJA;
	VALink = pMatrix->VALink;
	subInitMatrix();
	ReSetMatrixElement();
}
Esempio n. 5
0
static void
create_node(Subnet *parent_subnet, int the_entry)
{
  Node *new_node;
  new_node = MallocNew(Node);
  parent_subnet->entry[the_entry] = (void *) new_node;
  clear_node(new_node);

  alloced += sizeof (Node);

  if (n_nodes == max_nodes) {
    if (nodes) {
      assert(max_nodes > 0);
      max_nodes *= 2;
      nodes = ReallocArray(Node *, max_nodes, nodes);
    } else {
      assert(max_nodes == 0);
      max_nodes = 16;
      nodes = MallocArray(Node *, max_nodes);
    }
    alloced += sizeof (Node *) * (max_nodes - n_nodes);
  }
Esempio n. 6
0
void COMPLEXSPAREMATRIX::subMallocSpace(int tRow, int tElement)
{
	MallocNew(VG, real, tElement);
	MallocNew(VB, real, tElement);
}