function ib = bandwidth ( triangle_num, triangle_node, ... node_num, node_p_variable, node_u_variable, node_v_variable ) %% BANDWIDTH determines the bandwidth of the coefficient matrix. % % Discussion: % % We take the bandwidth to be the maximum difference between the % indices of two variables associated with nodes that share a triangle. % % Therefore, we can compute the bandwidth by examining each triangle, % and finding the maximum difference in indices of any two variables % associated with nodes in that triangle. % % Modified: % % 30 July 2005 % % Author: % % John Burkardt % % Parameters: % % Input, integer TRIANGLE_NUM, the number of triangles. % % Input, integer TRIANGLE_NODE(6,TRIANGLE_NUM); % TRIANGLE_NODE(I,J) is the global index of local node I in triangle J. % % Input, integer NODE_NUM, the number of nodes. % % Input, integer NODE_P_VARIABLE(NODE_NUM), % is the index of the pressure variable associated with the node, % or -1 if there is no associated pressure variable. % % Input, integer NODE_U_VARIABLE(NODE_NUM), % is the index of the horizontal velocity variable associated with the node. % % Input, integer NODE_V_VARIABLE(NODE_NUM), % is the index of the vertical velocity variable associated with the node. % % Output, integer IB, the half bandwidth of the matrix. % ib = 0; for triangle = 1 : triangle_num v_max = -i4_huge ( 'DUMMY' ); v_min = i4_huge ( 'DUMMY' ); for local = 1 : 6 node = triangle_node(local,triangle); v = node_u_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); v = node_v_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); if ( 0 < node_p_variable(node) ) v = node_p_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); end end ib = max ( ib, v_max - v_min ); end