def from_submatrices(cls, getsubmatrix, nm, points_target, points_source=None, **params):
        """Construct an instance of the class from a evaluation function.

        Parameters
        ----------
        points: np.ndarray of shape (N, 3)
            The coordinates of the points.
        getsubmatrix: Callable
            A function evaluating the matrix in a given range.
        epsilon: float, keyword-only, optional
            Tolerance of the Adaptive Cross Approximation
        eta: float, keyword-only, optional
            Criterion to choose the blocks to compress
        minclustersize: int, keyword-only, optional
            Minimum shape of a block
        maxblocksize: int, keyword-only, optional
            Maximum number of coefficients in a block

        Returns
        -------
        HMatrix or ComplexHMatrix
        """
        # Set params.
        cls._set_building_params(**params)

        # Boilerplate code for Python/C++ interface.
        _getsumatrix_func_type = ctypes.CFUNCTYPE(
                None, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
                ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes.c_double)
            )
        if points_source is None:
            cls.lib.MultiHMatrixCreatewithsubmatSym.restype = ctypes.POINTER(_C_MultiHMatrix)
            cls.lib.MultiHMatrixCreatewithsubmatSym.argtypes = [
                np.ctypeslib.ndpointer(dtype=np.float64, ndim=2, flags='C_CONTIGUOUS'),
                ctypes.c_int,
                _getsumatrix_func_type,
                ctypes.c_int
            ]

            # Call the C++ backend.
            c_data = cls.lib.MultiHMatrixCreatewithsubmatSym(points_target, points_target.shape[0], _getsumatrix_func_type(getsubmatrix),nm)
        else:
            cls.lib.MultiHMatrixCreatewithsubmat.restype = ctypes.POINTER(_C_MultiHMatrix)
            cls.lib.MultiHMatrixCreatewithsubmat.argtypes = [
                np.ctypeslib.ndpointer(dtype=np.float64, ndim=2, flags='C_CONTIGUOUS'),
                ctypes.c_int,
                np.ctypeslib.ndpointer(dtype=np.float64, ndim=2, flags='C_CONTIGUOUS'),
                ctypes.c_int,
                _getsumatrix_func_type,
                ctypes.c_int
            ]

            # Call the C++ backend.
            c_data = cls.lib.MultiHMatrixCreatewithsubmat(points_target,points_target.shape[0],points_source, points_source.shape[0], _getsumatrix_func_type(getsubmatrix),nm)

        return cls(c_data, **params)