// ComputeCapability returns the compute capability of the device.
// This method is a convenience method for the deprecated API call cuDeviceComputeCapability.
190485
func (d Device) ComputeCapability() (major, minor int, err error) {
	var attrs []int
	if attrs, err = d.Attributes(ComputeCapabilityMajor, ComputeCapabilityMinor); err != nil {
		err = errors.Wrapf(err, "Failed to get ComputeCapability")
		return
	}
	major = attrs[0]
	minor = attrs[1]
	return
}
1051644
func (me *Cache) SetCapacity(capacity int64) {
	me.mu.Lock()
	defer me.mu.Unlock()
	me.capacity = capacity
}
490530
func (c *cache) ensureCapacity(toAdd uint64) {
	mustRemove := int64(c.size+toAdd) - int64(c.cap)
	for mustRemove > 0 {
		key := c.keyList.Back().Value.(string)
		mustRemove -= int64(c.items[key].item.Size())
		c.remove(key)
	}
}
745082
func computeCardinalityLocked(exp *InternalExpectation) (min, max uint) {
	// Explicit cardinality.
	if exp.ExpectedNumMatches >= 0 {
		min = uint(exp.ExpectedNumMatches)
		max = min
		return
	}

	// Implicit count based on one-time actions.
	if len(exp.OneTimeActions) != 0 {
		min = uint(len(exp.OneTimeActions))
		max = min

		// If there is a fallback action, this is only a lower bound.
		if exp.FallbackAction != nil {
			max = math.MaxUint32
		}

		return
	}

	// Implicit lack of restriction based on a fallback action being configured.
	if exp.FallbackAction != nil {
		min = 0
		max = math.MaxUint32
		return
	}

	// Implicit cardinality of one.
	min = 1
	max = 1
	return
}
764421
func (f *ControllerClient) GetCapacity(ctx context.Context, in *csipb.GetCapacityRequest, opts ...grpc.CallOption) (*csipb.GetCapacityResponse, error) {
	return nil, nil
}
489100
func convertToRuntimeCapabilities(opts *v1.Capabilities) *runtimeapi.Capability {
	if opts == nil {
		return nil
	}

	capabilities := &runtimeapi.Capability{
		AddCapabilities:  make([]string, len(opts.Add)),
		DropCapabilities: make([]string, len(opts.Drop)),
	}
	for index, value := range opts.Add {
		capabilities.AddCapabilities[index] = string(value)
	}
	for index, value := range opts.Drop {
		capabilities.DropCapabilities[index] = string(value)
	}

	return capabilities
}
671596
func (a *allocReconciler) Compute() *reconcileResults {
	// Create the allocation matrix
	m := newAllocMatrix(a.job, a.existingAllocs)

	// Handle stopping unneeded deployments
	a.cancelDeployments()

	// If we are just stopping a job we do not need to do anything more than
	// stopping all running allocs
	if a.job.Stopped() {
		a.handleStop(m)
		return a.result
	}

	// Detect if the deployment is paused
	if a.deployment != nil {
		a.deploymentPaused = a.deployment.Status == structs.DeploymentStatusPaused
		a.deploymentFailed = a.deployment.Status == structs.DeploymentStatusFailed
	}

	// Reconcile each group
	complete := true
	for group, as := range m {
		groupComplete := a.computeGroup(group, as)
		complete = complete && groupComplete
	}

	// Mark the deployment as complete if possible
	if a.deployment != nil && complete {
		a.result.deploymentUpdates = append(a.result.deploymentUpdates, &structs.DeploymentStatusUpdate{
			DeploymentID:      a.deployment.ID,
			Status:            structs.DeploymentStatusSuccessful,
			StatusDescription: structs.DeploymentStatusDescriptionSuccessful,
		})
	}

	// Set the description of a created deployment
	if d := a.result.deployment; d != nil {
		if d.RequiresPromotion() {
			d.StatusDescription = structs.DeploymentStatusDescriptionRunningNeedsPromotion
		}
	}

	return a.result
}
602041
func (g *Generator) DropProcessCapabilityAmbient(c string) error {
	if g.Config == nil || g.Config.Process == nil || g.Config.Process.Capabilities == nil {
		return nil
	}

	cp := strings.ToUpper(c)
	for i, cap := range g.Config.Process.Capabilities.Ambient {
		if strings.ToUpper(cap) == cp {
			g.Config.Process.Capabilities.Ambient = removeFunc(g.Config.Process.Capabilities.Ambient, i)
		}
	}

	return validate.CapValid(cp, false)
}
1262304
func EmulationEnabled(c context.Context) bool {
	enabled, _ := c.Value(&emulationEnabledKey).(bool)
	return enabled
}
877710
func (s *FakeAWSServices) Compute(region string) (EC2, error) {
	return s.ec2, nil
}
553183
func (s *MockSigner) ComputeInputScript(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (*input.Script, error) {
	panic("not implemented")
}
496670
func (cfg *ChannelCfg) HasCapability(group fab.ConfigGroupKey, capability string) bool {
	groupCapabilities, ok := cfg.capabilities[group]
	if !ok {
		return false
	}
	if groupCapabilities[capability] {
		return true
	}

	// Special handling for version capabilities: V1_1 is supported if V1_2 or V1_3
	// are supported; V1_2 is supported if V1_3 is supported, etc.
	if isVersionCapability(capability) {
		for c := range groupCapabilities {
			if isVersionCapability(c) && c > capability {
				logger.Debugf("[%s] is greater than [%s] and therefore capability is supported", c, capability)
				return true
			}
		}
	}
	return false
}
783063
func (plugin ApplicationPluginFactory) Compute(arg1, arg2 int) int {
	return plugin.ComputeFn(arg1, arg2)
}
634009
func (s *IdentityServer) Capabilities(
	ctx context.Context,
	req *api.SdkIdentityCapabilitiesRequest,
) (*api.SdkIdentityCapabilitiesResponse, error) {

	capCluster := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_CLUSTER,
			},
		},
	}
	capCloudBackup := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_CLOUD_BACKUP,
			},
		},
	}
	capCredentials := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_CREDENTIALS,
			},
		},
	}
	capNode := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_NODE,
			},
		},
	}
	capObjectStorage := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_OBJECT_STORAGE,
			},
		},
	}
	capSchedulePolicy := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_SCHEDULE_POLICY,
			},
		},
	}
	capVolume := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_VOLUME,
			},
		},
	}
	capAlerts := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_ALERTS,
			},
		},
	}
	capMountAttach := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_MOUNT_ATTACH,
			},
		},
	}
	capRole := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_ROLE,
			},
		},
	}
	capClusterPair := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_CLUSTER_PAIR,
			},
		},
	}
	capMigrate := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_MIGRATE,
			},
		},
	}
	capStoragePolicy := &api.SdkServiceCapability{
		Type: &api.SdkServiceCapability_Service{
			Service: &api.SdkServiceCapability_OpenStorageService{
				Type: api.SdkServiceCapability_OpenStorageService_STORAGE_POLICY,
			},
		},
	}
	return &api.SdkIdentityCapabilitiesResponse{
		Capabilities: []*api.SdkServiceCapability{
			capCluster,
			capCloudBackup,
			capCredentials,
			capNode,
			capObjectStorage,
			capSchedulePolicy,
			capVolume,
			capAlerts,
			capMountAttach,
			capRole,
			capClusterPair,
			capMigrate,
			capStoragePolicy,
		},
	}, nil
}
166386
func (c *Connection) isCapable(featureName string) bool {
	capabilities, _ := c.Properties["capabilities"].(Table)
	hasFeature, _ := capabilities[featureName].(bool)
	return hasFeature
}
803529
func (v VirtualMachine) Device(ctx context.Context) (VirtualDeviceList, error) {
	var o mo.VirtualMachine

	err := v.Properties(ctx, v.Reference(), []string{"config.hardware.device", "summary.runtime.connectionState"}, &o)
	if err != nil {
		return nil, err
	}

	// Quoting the SDK doc:
	//   The virtual machine configuration is not guaranteed to be available.
	//   For example, the configuration information would be unavailable if the server
	//   is unable to access the virtual machine files on disk, and is often also unavailable
	//   during the initial phases of virtual machine creation.
	if o.Config == nil {
		return nil, fmt.Errorf("%s Config is not available, connectionState=%s",
			v.Reference(), o.Summary.Runtime.ConnectionState)
	}

	return VirtualDeviceList(o.Config.Hardware.Device), nil
}
493736
func (lrs *LinearRegressionSeries) computeCoefficients() {
	startIndex := lrs.GetOffset()
	endIndex := lrs.GetEndIndex()

	p := float64(endIndex - startIndex)

	xvalues := seq.NewBufferWithCapacity(lrs.Len())
	for index := startIndex; index < endIndex; index++ {
		x, _ := lrs.InnerSeries.GetValues(index)
		xvalues.Enqueue(x)
	}

	lrs.avgx = seq.Seq{Provider: xvalues}.Average()
	lrs.stddevx = seq.Seq{Provider: xvalues}.StdDev()

	var sumx, sumy, sumxx, sumxy float64
	for index := startIndex; index < endIndex; index++ {
		x, y := lrs.InnerSeries.GetValues(index)

		x = lrs.normalize(x)

		sumx += x
		sumy += y
		sumxx += x * x
		sumxy += x * y
	}

	lrs.m = (p*sumxy - sumx*sumy) / (p*sumxx - sumx*sumx)
	lrs.b = (sumy / p) - (lrs.m * sumx / p)
}