def get_density_matrix(self, surface_divider = <NUM_LIT>):
if self.__ccore_som_pointer is not None:<EOL><INDENT>self._weights = wrapper.som_get_weights(self.__ccore_som_pointer)<EOL><DEDENT>density_matrix = [[<NUM_LIT:0>] * self._cols for i in range(self._rows)]<EOL>dimension = len(self._weights[<NUM_LIT:0>])<EOL>dim_max = [ float('<STR_LIT>') ] * dimension<EOL>dim_min = [ float('<STR_LIT>') ] * dimension<EOL>for weight in self._weights:<EOL><INDENT>for index_dim in range(dimension):<EOL><INDENT>if weight[index_dim] > dim_max[index_dim]:<EOL><INDENT>dim_max[index_dim] = weight[index_dim]<EOL><DEDENT>if weight[index_dim] < dim_min[index_dim]:<EOL><INDENT>dim_min[index_dim] = weight[index_dim]<EOL><DEDENT><DEDENT><DEDENT>radius = [<NUM_LIT:0.0>] * len(self._weights[<NUM_LIT:0>])<EOL>for index_dim in range(dimension):<EOL><INDENT>radius[index_dim] = ( dim_max[index_dim] - dim_min[index_dim] ) / surface_divider<EOL><DEDENT>for point in self._data:<EOL><INDENT>for index_neuron in range(len(self)):<EOL><INDENT>point_covered = True<EOL>for index_dim in range(dimension):<EOL><INDENT>if abs(point[index_dim] - self._weights[index_neuron][index_dim]) > radius[index_dim]:<EOL><INDENT>point_covered = False<EOL>break<EOL><DEDENT><DEDENT>row = int(math.floor(index_neuron / self._cols))<EOL>col = index_neuron - row * self._cols<EOL>if point_covered is True:<EOL><INDENT>density_matrix[row][col] += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>return density_matrix<EOL>
!
        @brief Calculates density matrix (P-Matrix).

        @param[in] surface_divider (double): Divider in each dimension that affect radius for density measurement.

        @return (list) Density matrix (P-Matrix).

        @see get_distance_matrix()