(A+)자료구조 (희소행렬)
본 자료는 5페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
해당 자료는 5페이지 까지만 미리보기를 제공합니다.
5페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

(A+)자료구조 (희소행렬)에 대한 보고서 자료입니다.

본문내용

m_cols, num_heads, i, j;
int row, col, value, current_row;
int done = FALSE;
matrix_pointer temp, last, mult_node = NULL, find_node;
matrix_pointer mult_hdnode[MAX_SIZE];
matrix_pointer m1_head, m2_head, m1_temp, m2_temp;
if(m1->u.entry.col == m2->u.entry.row)
{
m1_head = m1->right;
m2_head = m2->right;
num_rows = m1->u.entry.row;
num_cols = m2->u.entry.col;
num_heads = (num_cols > num_rows) ? num_cols : num_rows;
mult_node = new_node();
mult_node->tag = entry;
mult_node->u.entry.row = num_rows;
mult_node->u.entry.col = num_cols;
if(!num_heads)
mult_node->right = mult_node;
else
{
for(i = 0; i < num_heads; i++)
{
temp = new_node();
mult_hdnode[i] = temp;
mult_hdnode[i]->tag = head;
mult_hdnode[i]->right = temp;
mult_hdnode[i]->u.next = temp;
}
current_row = 0;
last = mult_hdnode[0];
for(i = 0; i < m1->u.entry.row; i++)
{
row = 0, col = 0, value = 0;
for(j = 0; j < m2->u.entry.col; )
{
if(j == 0 && done == FALSE)
{
m1_temp = m1_head->right;
m2_temp = m2_head->down;
}
if(m2_temp->tag == head || m2_temp->down == m2_temp)
{
done = FALSE;
m2_head = m2_head->u.next;
m2_temp = m2_head->down;
m1_temp = m1_head->right;
row = 0, col = 0, value = 0;
j++;
}
if(m1_temp->tag == head)
{
if(m1_temp->right == m1_temp)
{
done = FALSE;
break;
}
if(m2_head->u.next != m2)
{
m1_temp = m1_head->right;
row = 0, col = 0, value = 0;
m2_head = m2_head->u.next;
m2_temp = m2_head->down;
done = FALSE;
j++;
}
else
j++;
}
if(j >= m2->u.entry.col )
break;
switch(COMPARE(m1_temp->u.entry.col, m2_temp->u.entry.row))
{
case -1:
m1_temp = m1_temp->right;
done = TRUE;
continue;
case 0:
done = TRUE;
if(value != 0)
{
row = m1_temp->u.entry.row;
col = m2_temp->u.entry.col;
find_node = mult_hdnode[row]->right;while(1)
{
if(find_node->u.entry.col == col)
{find_node->u.entry.value =
find_node->u.entry.value + value;
break;
}
else
find_node = find_node->right;if(find_node->tag == head)
break;
}
m1_temp = m1_temp->right;
m2_temp = m2_temp->down;
}
else if(value == 0)
{row = m1_temp->u.entry.row;
col = m2_temp->u.entry.col;
value = m1_temp->u.entry.value * m2_temp->u.entry.value;
if(row > current_row)
{last->right = mult_hdnode[current_row];
current_row = row;
last = mult_hdnode[row];
}
temp = new_node();
temp->tag = entry;
temp->u.entry.row = row;
temp->u.entry.col = col;
temp->u.entry.value = value;
last->right = temp;
last = temp;
mult_hdnode[col]->u.next->down = temp;
mult_hdnode[col]->u.next = temp;
m1_temp = m1_temp->right;
m2_temp = m2_temp->down;
}
continue;
case 1:
done = TRUE;
m2_temp = m2_temp->down;
continue;
}
}
m1_head = m1_head->u.next;
m2_head = m2->right;
done = FALSE;
}
last->right = mult_hdnode[current_row];
for(i = 0; i < num_cols; i++)
mult_hdnode[i]->u.next->down = mult_hdnode[i];
for(i = 0; i < num_heads-1; i++)
mult_hdnode[i]->u.next = mult_hdnode[i+1];
mult_hdnode[num_heads-1]->u.next = mult_node;
mult_node->right = mult_hdnode[0];
}
}
else
{
printf(\"행렬의 곱을 하기 위한 조건에 맞지 않습니다.\\n\");
printf(\"조건: 앞 행렬의 열과 뒤 행렬의 행의 개수가 같아야 가능하다\\n\");
return NULL;
}
return mult_node;
}

키워드

  • 가격2,000
  • 페이지수15페이지
  • 등록일2011.11.27
  • 저작시기2021.1
  • 파일형식한글(hwp)
  • 자료번호#716880
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니