matrix_coo.F90 Source File


This file depends on

sourcefile~~matrix_coo.f90~~EfferentGraph sourcefile~matrix_coo.f90 matrix_coo.F90 sourcefile~allocate.f90 allocate.F90 sourcefile~matrix_coo.f90->sourcefile~allocate.f90 sourcefile~deallocate.f90 deallocate.F90 sourcefile~matrix_coo.f90->sourcefile~deallocate.f90 sourcefile~matrix_interface.f90 matrix_interface.F90 sourcefile~matrix_coo.f90->sourcefile~matrix_interface.f90 sourcefile~error.f90 error.F90 sourcefile~allocate.f90->sourcefile~error.f90 sourcefile~deallocate.f90->sourcefile~error.f90

Files dependent on this one

sourcefile~~matrix_coo.f90~~AfferentGraph sourcefile~matrix_coo.f90 matrix_coo.F90 sourcefile~matrix.f90 matrix.F90 sourcefile~matrix.f90->sourcefile~matrix_coo.f90 sourcefile~types.f90 types.F90 sourcefile~types.f90->sourcefile~matrix.f90 sourcefile~core.f90 core.F90 sourcefile~core.f90->sourcefile~types.f90 sourcefile~vtk.f90 vtk.F90 sourcefile~core.f90->sourcefile~vtk.f90 sourcefile~vtk.f90->sourcefile~types.f90 sourcefile~adjacency_element.f90 adjacency_element.F90 sourcefile~adjacency_element.f90->sourcefile~core.f90 sourcefile~mesh.f90 mesh.F90 sourcefile~adjacency_element.f90->sourcefile~mesh.f90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~adjacency_node.f90->sourcefile~core.f90 sourcefile~adjacency_node.f90->sourcefile~mesh.f90 sourcefile~boundary_interface.f90 boundary_interface.F90 sourcefile~boundary_interface.f90->sourcefile~core.f90 sourcefile~domain.f90 domain.F90 sourcefile~boundary_interface.f90->sourcefile~domain.f90 sourcefile~input.f90 input.F90 sourcefile~boundary_interface.f90->sourcefile~input.f90 sourcefile~boundary_manager.f90 boundary_manager.F90 sourcefile~boundary_manager.f90->sourcefile~core.f90 sourcefile~boundary_manager.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_manager.f90->sourcefile~domain.f90 sourcefile~boundary_manager.f90->sourcefile~input.f90 sourcefile~control.f90 control.F90 sourcefile~control.f90->sourcefile~core.f90 sourcefile~time.f90 time.F90 sourcefile~control.f90->sourcefile~time.f90 sourcefile~control.f90->sourcefile~input.f90 sourcefile~iteration.f90 iteration.F90 sourcefile~control.f90->sourcefile~iteration.f90 sourcefile~openmp.f90 openmp.F90 sourcefile~control.f90->sourcefile~openmp.f90 sourcefile~density_interface.f90 density_interface.F90 sourcefile~density_interface.f90->sourcefile~core.f90 sourcefile~density_interface.f90->sourcefile~input.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain_manager.f90->sourcefile~core.f90 sourcefile~multicoloring.f90 multicoloring.F90 sourcefile~domain_manager.f90->sourcefile~multicoloring.f90 sourcefile~reordering.f90 reordering.F90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~adjacency.f90 adjacency.F90 sourcefile~domain_manager.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90->sourcefile~input.f90 sourcefile~domain_manager.f90->sourcefile~mesh.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~element_factory.f90->sourcefile~core.f90 sourcefile~element_interface.f90 element_interface.F90 sourcefile~element_factory.f90->sourcefile~element_interface.f90 sourcefile~element_factory.f90->sourcefile~input.f90 sourcefile~element_interface.f90->sourcefile~core.f90 sourcefile~mesh_interface.f90 mesh_interface.F90 sourcefile~element_interface.f90->sourcefile~mesh_interface.f90 sourcefile~element_interface.f90->sourcefile~input.f90 sourcefile~ftdss.f90 ftdss.F90 sourcefile~ftdss.f90->sourcefile~core.f90 sourcefile~ftdss.f90->sourcefile~control.f90 sourcefile~boundary.f90 boundary.F90 sourcefile~ftdss.f90->sourcefile~boundary.f90 sourcefile~ftdss.f90->sourcefile~domain.f90 sourcefile~hydraulic.f90 hydraulic.F90 sourcefile~ftdss.f90->sourcefile~hydraulic.f90 sourcefile~initial.f90 initial.F90 sourcefile~ftdss.f90->sourcefile~initial.f90 sourcefile~ftdss.f90->sourcefile~input.f90 sourcefile~output.f90 output.F90 sourcefile~ftdss.f90->sourcefile~output.f90 sourcefile~properties.f90 properties.F90 sourcefile~ftdss.f90->sourcefile~properties.f90 sourcefile~thermal.f90 thermal.F90 sourcefile~ftdss.f90->sourcefile~thermal.f90 sourcefile~gcc_interface.f90 gcc_interface.F90 sourcefile~gcc_interface.f90->sourcefile~core.f90 sourcefile~gcc_interface.f90->sourcefile~input.f90 sourcefile~hcf_interface.f90 hcf_interface.F90 sourcefile~hcf_interface.f90->sourcefile~core.f90 sourcefile~hcf_interface.f90->sourcefile~input.f90 sourcefile~heat_capacity_interface.f90 heat_capacity_interface.F90 sourcefile~heat_capacity_interface.f90->sourcefile~core.f90 sourcefile~heat_capacity_interface.f90->sourcefile~density_interface.f90 sourcefile~input_interface.f90 input_interface.F90 sourcefile~heat_capacity_interface.f90->sourcefile~input_interface.f90 sourcefile~hydraulic_assemble.f90 hydraulic_assemble.F90 sourcefile~hydraulic_assemble.f90->sourcefile~core.f90 sourcefile~hydraulic_assemble.f90->sourcefile~control.f90 sourcefile~calculate.f90 calculate.F90 sourcefile~hydraulic_assemble.f90->sourcefile~calculate.f90 sourcefile~hydraulic_assemble.f90->sourcefile~domain.f90 sourcefile~hydraulic_assemble.f90->sourcefile~properties.f90 sourcefile~hydraulic_interface.f90 hydraulic_interface.F90 sourcefile~hydraulic_interface.f90->sourcefile~core.f90 sourcefile~hydraulic_interface.f90->sourcefile~control.f90 sourcefile~hydraulic_interface.f90->sourcefile~hydraulic_assemble.f90 sourcefile~hydraulic_interface.f90->sourcefile~boundary.f90 sourcefile~hydraulic_interface.f90->sourcefile~calculate.f90 sourcefile~hydraulic_interface.f90->sourcefile~domain.f90 sourcefile~hydraulic_interface.f90->sourcefile~input.f90 sourcefile~hydraulic_interface.f90->sourcefile~properties.f90 sourcefile~solver.f90 solver.F90 sourcefile~hydraulic_interface.f90->sourcefile~solver.f90 sourcefile~initial_interface.f90 initial_interface.F90 sourcefile~initial_interface.f90->sourcefile~core.f90 sourcefile~initial_interface.f90->sourcefile~boundary.f90 sourcefile~initial_interface.f90->sourcefile~domain.f90 sourcefile~initial_interface.f90->sourcefile~input.f90 sourcefile~initial_manager.f90 initial_manager.F90 sourcefile~initial_manager.f90->sourcefile~core.f90 sourcefile~initial_manager.f90->sourcefile~initial_interface.f90 sourcefile~initial_manager.f90->sourcefile~domain.f90 sourcefile~initial_manager.f90->sourcefile~input.f90 sourcefile~input_interface.f90->sourcefile~core.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~matrix_ops.f90 matrix_ops.F90 sourcefile~matrix_ops.f90->sourcefile~core.f90 sourcefile~matvec.f90 matvec.F90 sourcefile~matvec.f90->sourcefile~core.f90 sourcefile~mesh_interface.f90->sourcefile~core.f90 sourcefile~multicoloring.f90->sourcefile~core.f90 sourcefile~multicoloring.f90->sourcefile~adjacency_element.f90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_interface.f90->sourcefile~core.f90 sourcefile~output_interface.f90->sourcefile~control.f90 sourcefile~output_interface.f90->sourcefile~project_settings.f90 sourcefile~output_interface.f90->sourcefile~domain.f90 sourcefile~output_interface.f90->sourcefile~input.f90 sourcefile~output_interface.f90->sourcefile~properties.f90 sourcefile~project_settings.f90->sourcefile~core.f90 sourcefile~properties_manager.f90 properties_manager.F90 sourcefile~properties_manager.f90->sourcefile~core.f90 sourcefile~properties_manager.f90->sourcefile~control.f90 sourcefile~properties_manager.f90->sourcefile~calculate.f90 sourcefile~properties_manager.f90->sourcefile~input.f90 sourcefile~materials_manager.f90 materials_manager.F90 sourcefile~properties_manager.f90->sourcefile~materials_manager.f90 sourcefile~reordering.f90->sourcefile~core.f90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~reordering.f90->sourcefile~mesh.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~side_factory.f90->sourcefile~core.f90 sourcefile~side_interface.f90 side_interface.F90 sourcefile~side_factory.f90->sourcefile~side_interface.f90 sourcefile~side_factory.f90->sourcefile~input.f90 sourcefile~side_interface.f90->sourcefile~core.f90 sourcefile~side_interface.f90->sourcefile~mesh_interface.f90 sourcefile~side_interface.f90->sourcefile~input.f90 sourcefile~solver_factory.f90 solver_factory.F90 sourcefile~solver_factory.f90->sourcefile~core.f90 sourcefile~solver_factory.f90->sourcefile~input.f90 sourcefile~specific_heat_interface.f90 specific_heat_interface.F90 sourcefile~specific_heat_interface.f90->sourcefile~core.f90 sourcefile~specific_heat_interface.f90->sourcefile~input.f90 sourcefile~thermal_conductivity_interface.f90 thermal_conductivity_interface.F90 sourcefile~thermal_conductivity_interface.f90->sourcefile~core.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~input.f90 sourcefile~thermal_interface.f90 thermal_interface.F90 sourcefile~thermal_interface.f90->sourcefile~core.f90 sourcefile~thermal_interface.f90->sourcefile~control.f90 sourcefile~thermal_interface.f90->sourcefile~boundary.f90 sourcefile~thermal_interface.f90->sourcefile~calculate.f90 sourcefile~thermal_interface.f90->sourcefile~domain.f90 sourcefile~thermal_interface.f90->sourcefile~input.f90 sourcefile~thermal_interface.f90->sourcefile~properties.f90 sourcefile~thermal_interface.f90->sourcefile~solver.f90 sourcefile~time.f90->sourcefile~core.f90 sourcefile~time.f90->sourcefile~input.f90 sourcefile~adjacency.f90->sourcefile~adjacency_element.f90 sourcefile~adjacency.f90->sourcefile~adjacency_node.f90 sourcefile~adjacency_node_element.f90 adjacency_node_element.F90 sourcefile~adjacency.f90->sourcefile~adjacency_node_element.f90 sourcefile~boundary.f90->sourcefile~boundary_interface.f90 sourcefile~boundary.f90->sourcefile~boundary_manager.f90 sourcefile~boundary_adiabatic.f90 boundary_adiabatic.F90 sourcefile~boundary_adiabatic.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_base.f90 boundary_base.F90 sourcefile~boundary_base.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_dirichlet.f90 boundary_dirichlet.F90 sourcefile~boundary_dirichlet.f90->sourcefile~boundary_interface.f90 sourcefile~calculate.f90->sourcefile~density_interface.f90 sourcefile~calculate.f90->sourcefile~gcc_interface.f90 sourcefile~calculate.f90->sourcefile~hcf_interface.f90 sourcefile~calculate.f90->sourcefile~heat_capacity_interface.f90 sourcefile~calculate.f90->sourcefile~specific_heat_interface.f90 sourcefile~calculate.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~linalg.f90 linalg.F90 sourcefile~calculate.f90->sourcefile~linalg.f90 sourcefile~density_3phase.f90 density_3phase.F90 sourcefile~density_3phase.f90->sourcefile~density_interface.f90 sourcefile~density_base.f90 density_base.F90 sourcefile~density_base.f90->sourcefile~density_interface.f90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~domain.f90->sourcefile~multicoloring.f90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~domain.f90->sourcefile~adjacency.f90 sourcefile~domain.f90->sourcefile~mesh.f90 sourcefile~dsatur.f90 dsatur.F90 sourcefile~dsatur.f90->sourcefile~multicoloring.f90 sourcefile~element.f90 element.F90 sourcefile~element.f90->sourcefile~element_factory.f90 sourcefile~element.f90->sourcefile~element_interface.f90 sourcefile~element_square_first.f90 element_square_first.F90 sourcefile~element_square_first.f90->sourcefile~element_interface.f90 sourcefile~element_square_second.f90 element_square_second.F90 sourcefile~element_square_second.f90->sourcefile~element_interface.f90 sourcefile~element_triangle_first.f90 element_triangle_first.F90 sourcefile~element_triangle_first.f90->sourcefile~element_interface.f90 sourcefile~element_triangle_second.f90 element_triangle_second.F90 sourcefile~element_triangle_second.f90->sourcefile~element_interface.f90 sourcefile~gcc_base.f90 gcc_base.F90 sourcefile~gcc_base.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_non_segregation_m.f90 gcc_non_segregation_m.F90 sourcefile~gcc_non_segregation_m.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_non_segregation_pa.f90 gcc_non_segregation_pa.F90 sourcefile~gcc_non_segregation_pa.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_segregation_m.f90 gcc_segregation_m.F90 sourcefile~gcc_segregation_m.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_segregation_pa.f90 gcc_segregation_pa.F90 sourcefile~gcc_segregation_pa.f90->sourcefile~gcc_interface.f90 sourcefile~hcf_base.f90 hcf_base.F90 sourcefile~hcf_base.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_bc.f90 hcf_bc.F90 sourcefile~hcf_bc.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_durner.f90 hcf_durner.F90 sourcefile~hcf_durner.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_dvgch.f90 hcf_dvgch.F90 sourcefile~hcf_dvgch.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_impedance.f90 hcf_impedance.F90 sourcefile~hcf_impedance.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_ko.f90 hcf_ko.F90 sourcefile~hcf_ko.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_mvg.f90 hcf_mvg.F90 sourcefile~hcf_mvg.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_vg.f90 hcf_vg.F90 sourcefile~hcf_vg.f90->sourcefile~hcf_interface.f90 sourcefile~hcf_viscosity.f90 hcf_viscosity.F90 sourcefile~hcf_viscosity.f90->sourcefile~hcf_interface.f90 sourcefile~heat_capacity_3phase.f90 heat_capacity_3phase.F90 sourcefile~heat_capacity_3phase.f90->sourcefile~heat_capacity_interface.f90 sourcefile~heat_capacity_3phase_apparent.f90 heat_capacity_3phase_apparent.F90 sourcefile~heat_capacity_3phase_apparent.f90->sourcefile~heat_capacity_interface.f90 sourcefile~heat_capacity_base.f90 heat_capacity_base.F90 sourcefile~heat_capacity_base.f90->sourcefile~heat_capacity_interface.f90 sourcefile~hydraulic.f90->sourcefile~hydraulic_interface.f90 sourcefile~hydraulic_crs.f90 hydraulic_crs.F90 sourcefile~hydraulic_crs.f90->sourcefile~hydraulic_interface.f90 sourcefile~initial.f90->sourcefile~initial_interface.f90 sourcefile~initial.f90->sourcefile~initial_manager.f90 sourcefile~initial_laplace.f90 initial_laplace.F90 sourcefile~initial_laplace.f90->sourcefile~initial_interface.f90 sourcefile~initial_uniform.f90 initial_uniform.F90 sourcefile~initial_uniform.f90->sourcefile~initial_interface.f90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~input_basic.f90 input_basic.F90 sourcefile~input_basic.f90->sourcefile~input_interface.f90 sourcefile~input_conditions.f90 input_conditions.F90 sourcefile~input_conditions.f90->sourcefile~input_interface.f90 sourcefile~input_geometry.f90 input_geometry.F90 sourcefile~input_geometry.f90->sourcefile~input_interface.f90 sourcefile~input_output.f90 input_output.F90 sourcefile~input_output.f90->sourcefile~input_interface.f90 sourcefile~lfo.f90 lfo.F90 sourcefile~lfo.f90->sourcefile~multicoloring.f90 sourcefile~linalg.f90->sourcefile~matrix_ops.f90 sourcefile~linalg.f90->sourcefile~matvec.f90 sourcefile~mesh.f90->sourcefile~mesh_interface.f90 sourcefile~mesh.f90->sourcefile~element.f90 sourcefile~side.f90 side.F90 sourcefile~mesh.f90->sourcefile~side.f90 sourcefile~methods.f90 methods.F90 sourcefile~methods.f90->sourcefile~reordering.f90 sourcefile~output.f90->sourcefile~output_interface.f90 sourcefile~output_base.f90 output_base.F90 sourcefile~output_base.f90->sourcefile~output_interface.f90 sourcefile~output_observation.f90 output_observation.F90 sourcefile~output_observation.f90->sourcefile~output_interface.f90 sourcefile~output_overall_base.f90 output_overall_base.F90 sourcefile~output_overall_base.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtk.f90 output_overall_vtk.F90 sourcefile~output_overall_vtk.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtu.f90 output_overall_vtu.F90 sourcefile~output_overall_vtu.f90->sourcefile~output_interface.f90 sourcefile~output_system_logger.f90 output_system_logger.F90 sourcefile~output_system_logger.f90->sourcefile~output_interface.f90 sourcefile~properties.f90->sourcefile~properties_manager.f90 sourcefile~properties.f90->sourcefile~materials_manager.f90 sourcefile~side.f90->sourcefile~side_factory.f90 sourcefile~side.f90->sourcefile~side_interface.f90 sourcefile~side_first.f90 side_first.F90 sourcefile~side_first.f90->sourcefile~side_interface.f90 sourcefile~side_second.f90 side_second.F90 sourcefile~side_second.f90->sourcefile~side_interface.f90 sourcefile~solver.f90->sourcefile~solver_factory.f90 sourcefile~specific_heat_3phase.f90 specific_heat_3phase.F90 sourcefile~specific_heat_3phase.f90->sourcefile~specific_heat_interface.f90 sourcefile~specific_heat_base.f90 specific_heat_base.F90 sourcefile~specific_heat_base.f90->sourcefile~specific_heat_interface.f90 sourcefile~thermal.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_conductivity_3phase.f90 thermal_conductivity_3phase.F90 sourcefile~thermal_conductivity_3phase.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~thermal_conductivity_base.f90 thermal_conductivity_base.F90 sourcefile~thermal_conductivity_base.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~thermal_crs.f90 thermal_crs.F90 sourcefile~thermal_crs.f90->sourcefile~thermal_interface.f90 sourcefile~to_original.f90 to_original.F90 sourcefile~to_original.f90->sourcefile~reordering.f90 sourcefile~to_reordered.f90 to_reordered.F90 sourcefile~to_reordered.f90->sourcefile~reordering.f90 sourcefile~welch_powell.f90 welch_powell.F90 sourcefile~welch_powell.f90->sourcefile~multicoloring.f90 sourcefile~adjacency_node_element.f90->sourcefile~mesh.f90 sourcefile~iteration.f90->sourcefile~calculate.f90 sourcefile~iteration.f90->sourcefile~input.f90 sourcefile~materials_manager.f90->sourcefile~calculate.f90 sourcefile~materials_manager.f90->sourcefile~input.f90 sourcefile~openmp.f90->sourcefile~input.f90

Source Code

module core_types_matrix_coo
    use, intrinsic :: iso_fortran_env
    use :: core_allocate, only:allocate_array
    use :: core_deallocate, only:deallocate_array
    use :: core_types_matrix, only:abst_matrix
    implicit none
    private

    public :: type_coo
    ! public :: type_coo_gemv
    ! public :: type_coo_add

    type, extends(abst_matrix) :: type_coo
        integer(int32) :: nnz = 0 ! number of non-zero elements
        integer(int32), allocatable :: row(:)
        integer(int32), allocatable :: col(:)
        real(real64),   allocatable :: val(:) !& non-zero values
    contains
        procedure, public, pass(self) :: initialize => initialize_type_coo !&
        procedure, public, pass(self) :: find       => find_coo !&
        procedure, public, pass(self) :: set        => set_coo !&
        procedure, public, pass(self) :: set_all    => set_all_coo !&
        procedure, public, pass(self) :: zero       => zero_coo !&
        procedure, public, pass(self) :: add        => add_coo !&
        procedure, public, pass(self) :: destroy    => destroy_coo !&
    end type

contains

    subroutine initialize_type_coo(self, num_nodes, row, col)
        implicit none
        class(type_coo), intent(inout) :: self
        integer(int32), intent(in) :: num_nodes
        integer(int32), intent(in), optional :: row(:)
        integer(int32), intent(in), optional :: col(:)

        integer(int32) :: i

        if (.not. present(row) .or. .not. present(col)) then
            print *, "Error: row and col must be provided for COO initialization."
            stop
        end if

        self%nnz = size(row)

        call allocate_array(self%row, self%nnz)
        do i = 1, self%nnz
            self%row(i) = row(i)
        end do

        call allocate_array(self%col, self%nnz)
        call allocate_array(self%val, self%nnz)
        do i = 1, self%nnz
            self%col(i) = col(i)
            self%val(i) = 0.0d0
        end do

    end subroutine initialize_type_coo

    pure function find_coo(self, row, col) result(index)
        implicit none
        class(type_coo), intent(in) :: self
        integer(int32), intent(in) :: row
        integer(int32), intent(in) :: col
        integer(int32) :: index

        integer(int32) :: i

        if (self%nnz == 0) then
            index = -1
            return
        end if

        ! --- 二分探索で行と列の組み合わせを探す ---
        index = -1
        do i = 1, self%nnz
            if (self%row(i) == row .and. self%col(i) == col) then
                index = i
                return
            end if
        end do
    end function find_coo

    subroutine set_coo(self, row, col, value)
        implicit none
        class(type_coo), intent(inout) :: self
        integer(int32), intent(in) :: row, col
        real(real64), intent(in) :: value

        integer(int32) :: index

        index = self%find(row, col)
        self%val(index) = value

    end subroutine set_coo

    subroutine set_all_coo(self, value)
        implicit none
        class(type_coo), intent(inout) :: self
        real(real64), intent(in) :: value

        integer(int32) :: i

        do i = 1, self%nnz
            self%val(i) = value
        end do

    end subroutine set_all_coo

    subroutine zero_coo(self)
        implicit none
        class(type_coo), intent(inout) :: self

        call self%set_all(0.0d0)

    end subroutine zero_coo

    subroutine add_coo(self, row, col, value)
        implicit none
        class(type_coo), intent(inout) :: self
        integer(int32), intent(in) :: row, col
        real(real64), intent(in) :: value

        integer(int32) :: index

        index = self%find(row, col)
        self%val(index) = self%val(index) + value

    end subroutine add_coo

    subroutine destroy_coo(self)
        implicit none
        class(type_coo), intent(inout) :: self

        ! --- COO構造の解放 ---
        call deallocate_array(self%row)
        call deallocate_array(self%col)
        call deallocate_array(self%val)

        self%nnz = 0
    end subroutine destroy_coo

end module core_types_matrix_coo